#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;
vector<tuple<int,int,int>>v(N);
int x=0;
for(int i=0;i<N;i++){
string S;
cin>>S;
int y=0,z=0;
for(char c:S){
if(c=='('){
y++;
}
else{
y--;
z=min(z,y);
}
}
x+=y;
v[i]={z,y,i};
}
if(x!=0){
cout<<-1<<'\n';
return 0;
}
sort(v.rbegin(),v.rend());
vector<int>ans;
for(auto[z,y,i]:v){
if(x+z<0){
cout<<-1<<'\n';
return 0;
}
x+=y;
ans.push_back(i);
}
for(int i:ans){
cout<<i+1<<' ';
}
cout<<'\n';
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1700 KiB | ||||
2 | Accepted | 4ms | 2152 KiB | ||||
subtask2 | 0/11 | ||||||
3 | Accepted | 3ms | 2072 KiB | ||||
4 | Wrong answer | 3ms | 2308 KiB | ||||
5 | Wrong answer | 3ms | 2636 KiB | ||||
6 | Accepted | 3ms | 2580 KiB | ||||
7 | Accepted | 4ms | 3196 KiB | ||||
8 | Accepted | 4ms | 3144 KiB | ||||
subtask3 | 6/6 | ||||||
9 | Accepted | 4ms | 3236 KiB | ||||
10 | Accepted | 3ms | 3404 KiB | ||||
11 | Accepted | 3ms | 3708 KiB | ||||
subtask4 | 14/14 | ||||||
12 | Accepted | 4ms | 3820 KiB | ||||
13 | Accepted | 4ms | 3720 KiB | ||||
subtask5 | 0/23 | ||||||
14 | Wrong answer | 4ms | 3728 KiB | ||||
15 | Wrong answer | 3ms | 3584 KiB | ||||
subtask6 | 0/19 | ||||||
16 | Wrong answer | 4ms | 3528 KiB | ||||
17 | Wrong answer | 4ms | 3572 KiB | ||||
18 | Accepted | 4ms | 3852 KiB | ||||
19 | Wrong answer | 3ms | 4052 KiB | ||||
20 | Wrong answer | 3ms | 4256 KiB | ||||
21 | Wrong answer | 4ms | 4536 KiB | ||||
22 | Wrong answer | 3ms | 4632 KiB | ||||
23 | Wrong answer | 4ms | 4744 KiB | ||||
24 | Wrong answer | 3ms | 4840 KiB | ||||
subtask7 | 0/27 | ||||||
25 | Accepted | 4ms | 4740 KiB | ||||
26 | Wrong answer | 4ms | 4692 KiB | ||||
27 | Wrong answer | 4ms | 4864 KiB | ||||
28 | Wrong answer | 4ms | 4888 KiB | ||||
29 | Wrong answer | 7ms | 5200 KiB | ||||
30 | Wrong answer | 17ms | 7928 KiB | ||||
31 | Wrong answer | 4ms | 4768 KiB | ||||
32 | Wrong answer | 4ms | 4972 KiB | ||||
33 | Wrong answer | 4ms | 4748 KiB | ||||
34 | Wrong answer | 4ms | 4972 KiB | ||||
35 | Wrong answer | 3ms | 4540 KiB | ||||
36 | Wrong answer | 4ms | 5004 KiB | ||||
37 | Accepted | 3ms | 4536 KiB | ||||
38 | Wrong answer | 3ms | 4560 KiB | ||||
39 | Wrong answer | 8ms | 6320 KiB | ||||
40 | Wrong answer | 3ms | 4776 KiB | ||||
41 | Wrong answer | 3ms | 4704 KiB | ||||
42 | Accepted | 4ms | 4948 KiB | ||||
43 | Wrong answer | 3ms | 5012 KiB |