# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
968272 | 2024-04-23T09:11:33 Z | Isam | Superpozicija (COCI22_superpozicija) | C++17 | 16 ms | 3128 KB |
#include<bits/stdc++.h> using namespace std; int n, a[100002], b[100002]; string z; inline bool is_valid(string s){ int tot(0); for(register int i = 0; i < (int)s.size(); ++i){ tot += (s[i]=='('?1:-1); if(tot < 0) return false; } return !tot; } int ans[100002]; signed main(){ ios_base::sync_with_stdio(0), cin.tie(0); int T; cin >> T; function<void()> test_case = [](){ cin >> n >> z; z = '.' + z; string tmp = ""; for(register int i = 1; i <= n; ++i){ cin >> a[i] >> b[i]; if(z[a[i]] == '('){ z[b[i]] = '.'; ans[i] = 0; }else{ z[a[i]] = '.'; ans[i] = 1; } } if(n & 1) return cout << -1 << '\n', void(); for(register int i = 1; i <= n*2; ++i){ if(z[i] == '.') continue; tmp += z[i]; } if(is_valid(tmp)){ for(register int i = 1; i <= n; ++i) cout << ans[i] << ' '; }else{ cout << -1; } cout << '\n'; }; while(T--) test_case(); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 13 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 344 KB | Output is correct |
2 | Correct | 13 ms | 1628 KB | Output is correct |
3 | Correct | 11 ms | 1628 KB | Output is correct |
4 | Correct | 16 ms | 2140 KB | Output is correct |
5 | Correct | 12 ms | 2132 KB | Output is correct |
6 | Correct | 7 ms | 1880 KB | Output is correct |
7 | Correct | 9 ms | 2136 KB | Output is correct |
8 | Correct | 11 ms | 2400 KB | Output is correct |
9 | Correct | 16 ms | 3128 KB | Output is correct |
10 | Correct | 16 ms | 3080 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 344 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 13 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |