10436 | 2024-04-02 13:21:11 | 111 | Zárójel csere | cpp17 | Accepted 100/100 | 57ms | 22336 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++;
}
y=(y+1)/2;
cout<<y<<'\n';
while(y--){
cout<<a.back()<<' '<<b.front()<<'\n';
a.pop_back();
b.pop_front();
}
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1824 KiB | ||||
2 | Accepted | 3ms | 2056 KiB | ||||
3 | Accepted | 2ms | 2140 KiB | ||||
subtask2 | 33/33 | ||||||
4 | Accepted | 2ms | 2140 KiB | ||||
5 | Accepted | 3ms | 2244 KiB | ||||
6 | Accepted | 3ms | 2476 KiB | ||||
subtask3 | 44/44 | ||||||
7 | Accepted | 3ms | 2552 KiB | ||||
8 | Accepted | 3ms | 2816 KiB | ||||
9 | Accepted | 3ms | 3036 KiB | ||||
10 | Accepted | 3ms | 3020 KiB | ||||
11 | Accepted | 3ms | 3196 KiB | ||||
12 | Accepted | 3ms | 3244 KiB | ||||
subtask4 | 23/23 | ||||||
13 | Accepted | 8ms | 8540 KiB | ||||
14 | Accepted | 24ms | 10596 KiB | ||||
15 | Accepted | 8ms | 12508 KiB | ||||
16 | Accepted | 35ms | 14512 KiB | ||||
17 | Accepted | 12ms | 18008 KiB | ||||
18 | Accepted | 13ms | 19172 KiB | ||||
19 | Accepted | 13ms | 20044 KiB | ||||
20 | Accepted | 54ms | 21220 KiB | ||||
21 | Accepted | 56ms | 22336 KiB | ||||
22 | Accepted | 57ms | 22304 KiB | ||||
23 | Accepted | 52ms | 22288 KiB | ||||
24 | Accepted | 50ms | 22292 KiB |