#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
vector<pair<int,int>> t;
bool elobb(int a, int b){
if(t[a].first==t[b].first) return t[a].second<t[b].second;
return t[a].first>t[b].first;
}
int main(){
cin.tie(0); ios_base::sync_with_stdio(false);
int x; cin >> x;
int sum=0;
for(int i=0; i<x; i++){
string s; cin >> s; int a=0; int ma=0;
for(int j=0; j<s.length(); j++){
if(s[j]=='(') a++;
if(s[j]==')') a--;
ma=min(ma,a);
}
sum+=a;
t.push_back(make_pair(a,ma));
}
//if(sum!=0){cout << "-1"; return 0;}
vector<int> adat;
for(int i=0; i<x; i++) adat.push_back(i);
sort(adat.begin(), adat.end(), elobb);
for(int i=0; i<adat.size(); i++) cout << adat[i]+1 << ' ';
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1824 KiB | ||||
2 | Wrong answer | 4ms | 2204 KiB | ||||
subtask2 | 0/11 | ||||||
3 | Accepted | 3ms | 2320 KiB | ||||
4 | Wrong answer | 3ms | 2460 KiB | ||||
5 | Accepted | 3ms | 2688 KiB | ||||
6 | Accepted | 2ms | 2884 KiB | ||||
7 | Wrong answer | 4ms | 3224 KiB | ||||
8 | Wrong answer | 4ms | 3488 KiB | ||||
subtask3 | 0/6 | ||||||
9 | Accepted | 4ms | 3232 KiB | ||||
10 | Wrong answer | 4ms | 3516 KiB | ||||
11 | Wrong answer | 4ms | 3824 KiB | ||||
subtask4 | 14/14 | ||||||
12 | Accepted | 4ms | 3696 KiB | ||||
13 | Accepted | 4ms | 3736 KiB | ||||
subtask5 | 0/23 | ||||||
14 | Wrong answer | 4ms | 4116 KiB | ||||
15 | Wrong answer | 4ms | 4112 KiB | ||||
subtask6 | 0/19 | ||||||
16 | Wrong answer | 4ms | 4076 KiB | ||||
17 | Wrong answer | 4ms | 4284 KiB | ||||
18 | Wrong answer | 4ms | 4284 KiB | ||||
19 | Wrong answer | 4ms | 4212 KiB | ||||
20 | Wrong answer | 4ms | 4176 KiB | ||||
21 | Wrong answer | 4ms | 4240 KiB | ||||
22 | Wrong answer | 4ms | 4500 KiB | ||||
23 | Wrong answer | 4ms | 4456 KiB | ||||
24 | Wrong answer | 3ms | 4452 KiB | ||||
subtask7 | 0/27 | ||||||
25 | Wrong answer | 4ms | 4396 KiB | ||||
26 | Wrong answer | 4ms | 4560 KiB | ||||
27 | Wrong answer | 4ms | 4456 KiB | ||||
28 | Wrong answer | 4ms | 4452 KiB | ||||
29 | Accepted | 7ms | 4852 KiB | ||||
30 | Wrong answer | 17ms | 5888 KiB | ||||
31 | Wrong answer | 4ms | 4740 KiB | ||||
32 | Wrong answer | 4ms | 4804 KiB | ||||
33 | Wrong answer | 4ms | 4708 KiB | ||||
34 | Wrong answer | 4ms | 4820 KiB | ||||
35 | Wrong answer | 3ms | 4596 KiB | ||||
36 | Wrong answer | 4ms | 4820 KiB | ||||
37 | Wrong answer | 3ms | 4620 KiB | ||||
38 | Wrong answer | 4ms | 4644 KiB | ||||
39 | Wrong answer | 8ms | 5236 KiB | ||||
40 | Wrong answer | 3ms | 4648 KiB | ||||
41 | Wrong answer | 3ms | 4612 KiB | ||||
42 | Wrong answer | 4ms | 4896 KiB | ||||
43 | Wrong answer | 4ms | 4716 KiB |