104352024-04-02 13:20:25111Zárójel cserecpp17Wrong answer 0/10059ms22316 KiB
#include <bits/stdc++.h>
using namespace std;

#define int long long

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int N;
	cin>>N;
	string S;
	cin>>S;
	deque<int>a,b;
	int i=0,x=0,y=0;
	for(char c:S){
		if(c=='('){
			x++;
			a.push_back(i);
		}
		else{
			x--;
			b.push_back(i);
		}
		y=max(y,-x);
		i++;
	}
	cout<<y<<'\n';
	y=(y+1)/2;
	while(y--){
		cout<<a.back()<<' '<<b.front()<<'\n';
		a.pop_back();
		b.pop_front();
	}
	return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1824 KiB
2Wrong answer3ms2056 KiB
3Accepted3ms2248 KiB
subtask20/33
4Wrong answer3ms2480 KiB
5Accepted3ms2696 KiB
6Wrong answer3ms2888 KiB
subtask30/44
7Wrong answer3ms3092 KiB
8Wrong answer3ms3460 KiB
9Wrong answer3ms3400 KiB
10Wrong answer3ms3232 KiB
11Wrong answer3ms3488 KiB
12Wrong answer3ms3576 KiB
subtask40/23
13Wrong answer8ms8944 KiB
14Wrong answer24ms10748 KiB
15Wrong answer8ms12816 KiB
16Wrong answer34ms14620 KiB
17Wrong answer12ms18212 KiB
18Wrong answer12ms19256 KiB
19Wrong answer12ms19996 KiB
20Wrong answer52ms21136 KiB
21Wrong answer59ms22064 KiB
22Wrong answer57ms22284 KiB
23Wrong answer54ms22308 KiB
24Wrong answer50ms22316 KiB