#include <bits/stdc++.h>
using namespace std;
const int maxn = 100;
int n;
int a[maxn], b[maxn];
bool mark[maxn];
string s;
void solve()
{
cin >> n >> s;
for(int i = 0 ; i < n ; i++)
cin >> a[i] >> b[i];
for(int i = 0 ; i < n ; i++)
a[i]--, b[i]--;
for(int mask = 0 ; mask < (1 << n) ; mask++)
{
memset( mark , false , sizeof(mark) );
for(int i = 0 ; i < n ; i++)
mark[ (mask & (1 << i)) ? b[i] : a[i] ] = true;
int sum = 0;
bool good = true;
for(int i = 0 ; i < 2*n ; i++)
{
if( !mark[i] )
continue;
sum += (s[i] == '(') ? 1 : -1;
if( sum < 0 )
good = false;
}
if( sum == 0 && good )
{
for(int i = 0 ; i < n ; i++)
cout << ((mask & (1 << i)) ? 1 : 0) << " ";
cout << endl;
return;
}
}
cout << -1 << endl;
}
int main()
{
int t;
cin >> t;
while( t-- )
solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
220 ms |
420 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
220 ms |
420 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |