#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
bool ren(pair<int,pair<int,int>> a, pair<int,pair<int,int>> b){
if(a.second.first-a.second.second==b.second.first-b.second.second) return a.second.second < b.second.second;
if(a.second.second==b.second.second) return a.second.first-a.second.second > b.second.first-b.second.second;
return a.second.second < b.second.second;
}
int main(){
int n; cin >> n; bool y=false; int s=0;
vector<pair<int,pair<int,int>>> t;
for(int i=0; i<n; i++){
string x; cin >> x;
pair<int,int> act;
bool ok=true;
for(int j=0; j<(int)x.length(); j++){
if(x[j]=='(') act.first++;
else{
if(act.first>0) act.first--;
else{
act.second++;
ok=false;
}
}
}
y|=ok; s+=act.first-act.second;
t.push_back(make_pair(i+1,act));
}
sort(t.begin(), t.end(), ren);
for(auto it=t.begin(); it!=t.end(); it++) cout << (*it).first << ' ';
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1808 KiB | ||||
2 | Accepted | 8ms | 2228 KiB | ||||
subtask2 | 0/11 | ||||||
3 | Accepted | 3ms | 2388 KiB | ||||
4 | Wrong answer | 3ms | 2364 KiB | ||||
5 | Wrong answer | 3ms | 2524 KiB | ||||
6 | Accepted | 3ms | 2776 KiB | ||||
7 | Accepted | 8ms | 3372 KiB | ||||
8 | Wrong answer | 8ms | 3284 KiB | ||||
subtask3 | 0/6 | ||||||
9 | Accepted | 8ms | 3332 KiB | ||||
10 | Wrong answer | 8ms | 3288 KiB | ||||
11 | Wrong answer | 8ms | 3552 KiB | ||||
subtask4 | 14/14 | ||||||
12 | Accepted | 8ms | 3876 KiB | ||||
13 | Accepted | 7ms | 3944 KiB | ||||
subtask5 | 0/23 | ||||||
14 | Wrong answer | 8ms | 4152 KiB | ||||
15 | Wrong answer | 8ms | 3996 KiB | ||||
subtask6 | 0/19 | ||||||
16 | Wrong answer | 8ms | 3976 KiB | ||||
17 | Wrong answer | 8ms | 4100 KiB | ||||
18 | Accepted | 8ms | 4464 KiB | ||||
19 | Wrong answer | 8ms | 4420 KiB | ||||
20 | Wrong answer | 8ms | 4492 KiB | ||||
21 | Wrong answer | 6ms | 4464 KiB | ||||
22 | Wrong answer | 6ms | 4652 KiB | ||||
23 | Wrong answer | 6ms | 4680 KiB | ||||
24 | Wrong answer | 6ms | 4680 KiB | ||||
subtask7 | 0/27 | ||||||
25 | Wrong answer | 8ms | 4620 KiB | ||||
26 | Wrong answer | 8ms | 4892 KiB | ||||
27 | Wrong answer | 8ms | 5004 KiB | ||||
28 | Wrong answer | 9ms | 4976 KiB | ||||
29 | Wrong answer | 12ms | 5292 KiB | ||||
30 | Wrong answer | 27ms | 6560 KiB | ||||
31 | Wrong answer | 8ms | 4944 KiB | ||||
32 | Wrong answer | 8ms | 5124 KiB | ||||
33 | Wrong answer | 8ms | 4948 KiB | ||||
34 | Wrong answer | 9ms | 5008 KiB | ||||
35 | Wrong answer | 7ms | 4772 KiB | ||||
36 | Wrong answer | 9ms | 5216 KiB | ||||
37 | Wrong answer | 7ms | 5116 KiB | ||||
38 | Wrong answer | 8ms | 5200 KiB | ||||
39 | Wrong answer | 16ms | 6016 KiB | ||||
40 | Wrong answer | 4ms | 5020 KiB | ||||
41 | Wrong answer | 3ms | 4964 KiB | ||||
42 | Accepted | 7ms | 5184 KiB | ||||
43 | Wrong answer | 6ms | 5140 KiB |