Submission #879087

#TimeUsernameProblemLanguageResultExecution timeMemory
879087AloraSuperpozicija (COCI22_superpozicija)C++17
10 / 110
14 ms3448 KiB
#include <bits/stdc++.h> #define Alora "cownav" #define fi(i,a,b) for(int i = a; i <= b; i++) #define fid(i,a,b) for(int i = a; i >= b; i--) #define ll long long #define f first #define se second #define pii pair<int, int> #define getbit(i, j) ((i >> j) & 1) #define all(v) v.begin(), v.end() #define pb push_back #define maxn 200005 const int M = 1e9 + 7; using namespace std; int t, n, xd[maxn], ans[maxn]; string s; int main(){ ios_base::sync_with_stdio(0); cin.tie(NULL); if(fopen(Alora".inp", "r")){ freopen(Alora".inp", "r", stdin); freopen(Alora".out", "w", stdout);} cin >> t; while(t--){ cin >> n; cin >> s; s = ' ' + s; fi(i, 1, 2*n) xd[i] = 0, ans[i] = 0; fi(i, 1, n){ int a, b; cin >> a >> b; if(s[a] == '(') ans[i] = 0, xd[a] = 1; else ans[i] = 1, xd[b] = 1; } if(n % 2 == 1) {cout << -1 << '\n'; continue;} int A = 0; fi(i, 1, 2*n) if(xd[i]){ if(s[i] == '(') A++; else A--; if(A < 0) break; } if(A != 0) {cout << -1 << '\n'; continue;} fi(i, 1, n) cout << ans[i] << " "; cout << '\n'; } return 0; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:22:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |     freopen(Alora".inp", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:23:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |     freopen(Alora".out", "w", stdout);}
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...