#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.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;
vector<pair<int,pair<int,int>>> t;
for(int i=0; i<n; i++){
string x; cin >> x;
pair<int,int> act;
for(int j=0; j<(int)x.length(); j++){
if(x[j]=='(') act.first++;
else{
if(act.first>0) act.first--;
else{
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 | 2236 KiB | ||||
subtask2 | 0/11 | ||||||
3 | Accepted | 3ms | 2272 KiB | ||||
4 | Wrong answer | 3ms | 2524 KiB | ||||
5 | Wrong answer | 3ms | 2700 KiB | ||||
6 | Accepted | 3ms | 2804 KiB | ||||
7 | Accepted | 8ms | 3444 KiB | ||||
8 | Wrong answer | 8ms | 3532 KiB | ||||
subtask3 | 0/6 | ||||||
9 | Accepted | 8ms | 3220 KiB | ||||
10 | Wrong answer | 8ms | 3460 KiB | ||||
11 | Wrong answer | 8ms | 3408 KiB | ||||
subtask4 | 14/14 | ||||||
12 | Accepted | 8ms | 3728 KiB | ||||
13 | Accepted | 8ms | 3944 KiB | ||||
subtask5 | 0/23 | ||||||
14 | Wrong answer | 8ms | 3904 KiB | ||||
15 | Wrong answer | 8ms | 4024 KiB | ||||
subtask6 | 0/19 | ||||||
16 | Wrong answer | 8ms | 4216 KiB | ||||
17 | Wrong answer | 8ms | 4292 KiB | ||||
18 | Accepted | 8ms | 4536 KiB | ||||
19 | Wrong answer | 8ms | 4668 KiB | ||||
20 | Wrong answer | 8ms | 4420 KiB | ||||
21 | Wrong answer | 6ms | 4632 KiB | ||||
22 | Wrong answer | 6ms | 4572 KiB | ||||
23 | Wrong answer | 6ms | 4600 KiB | ||||
24 | Wrong answer | 6ms | 4700 KiB | ||||
subtask7 | 0/27 | ||||||
25 | Wrong answer | 8ms | 4660 KiB | ||||
26 | Wrong answer | 8ms | 4652 KiB | ||||
27 | Wrong answer | 9ms | 4704 KiB | ||||
28 | Wrong answer | 9ms | 4900 KiB | ||||
29 | Wrong answer | 13ms | 5392 KiB | ||||
30 | Wrong answer | 28ms | 6708 KiB | ||||
31 | Wrong answer | 8ms | 5348 KiB | ||||
32 | Wrong answer | 8ms | 5536 KiB | ||||
33 | Wrong answer | 8ms | 5360 KiB | ||||
34 | Wrong answer | 9ms | 5508 KiB | ||||
35 | Wrong answer | 7ms | 5168 KiB | ||||
36 | Wrong answer | 9ms | 5372 KiB | ||||
37 | Wrong answer | 7ms | 5152 KiB | ||||
38 | Wrong answer | 8ms | 5156 KiB | ||||
39 | Wrong answer | 14ms | 6020 KiB | ||||
40 | Wrong answer | 4ms | 5188 KiB | ||||
41 | Wrong answer | 3ms | 5132 KiB | ||||
42 | Accepted | 7ms | 5424 KiB | ||||
43 | Wrong answer | 6ms | 5272 KiB |