#include<iostream>
#include<vector>
#include<string>
#include<utility>
#include<algorithm>
using namespace std;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int t;
cin>>t;
while(t--){
int n;
cin>>n;
string s;
cin>>s;
vector<pair<int,int> > vec(n);
for(int i=0;i<n;i++) cin>>vec[i].first>>vec[i].second;
if(n&1){
cout<<"-1\n";
continue;
}
if(n<=10){
bool ff=0;
for(int i=0;i<(1<<n);i++){
string tmp;
for(int j=0;j<n;j++){
if(i&(1<<j)) tmp+=s[vec[j].second-1];
else tmp+=s[vec[j].first-1];
}
int now=0;
bool flag=1;
for(int j=0;j<n;j++){
if(tmp[j]=='(') now++;
else now--;
if(now<0){
flag=0;
break;
}
}
if(flag&&now==0){
for(int j=0;j<n;j++){
cout<<(i&1)<<" ";
i>>=1;
}
ff=1;
cout<<"\n";
break;
}
}
if(!ff) cout<<-1<<"\n";
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
131 ms |
1112 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
1116 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
131 ms |
1112 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |