Submission #666831

#TimeUsernameProblemLanguageResultExecution timeMemory
666831LawlietSuperpozicija (COCI22_superpozicija)C++17
0 / 110
220 ms420 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...