# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
730742 | 2023-04-26T10:54:12 Z | Augustyn | Superpozicija (COCI22_superpozicija) | C++17 | 36 ms | 3112 KB |
#include<bits/stdc++.h> using namespace std; #define f first #define s second #define pf printf #define pii pair<int,int> pii ab[200001]; char naw[200001]; int jb[200001],gr[200001]; int t,n; void rozw() { scanf("%d",&n); priority_queue<pii ,vector<pii >,greater<pii >>dod; getchar(); for(int i=0;i<n*2;++i) naw[i]=getchar(); for(int i=0;i<n;++i) { scanf("%d%d",&ab[i].f,&ab[i].s); --ab[i].f; --ab[i].s; gr[ab[i].f]=ab[i].s; gr[ab[i].s]=ab[i].f; } int ile=0; for(int i=0;i<2*n;++i) { if(naw[gr[i]]==naw[i]) { if(naw[i]=='('&&i<gr[i]) { jb[i]=t; jb[gr[i]]=-t; ++ile; } else if(naw[i]==')'&&i>gr[i]) { jb[i]=t; jb[gr[i]]=-t; --ile; } } else { if(jb[i]!=-t&&jb[i]!=t) { if(naw[i]=='(') { jb[i]=-t; jb[gr[i]]=t; dod.push({gr[i],i}); } else { jb[i]=t; jb[gr[i]]=-t; --ile; dod.push({gr[i],i}); } } else if(jb[i]==t) { ile++; if(naw[i]==')') ile-=2; } } if(ile<0) { if(dod.empty()) { pf("-1\n"); return; } jb[dod.top().s]*=-1; jb[dod.top().f]*=-1; ++ile; if(max(dod.top().f,dod.top().s)<=i) ++ile; dod.pop(); } } if(ile!=0) { pf("-1\n"); return; } for(int i=0;i<n;++i) { if(jb[ab[i].f]==t) pf("0 "); else pf("1 "); } pf("\n"); } int main() { n=1000000; int xd[n]; scanf("%d",&t); while(t) { rozw(); --t; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 25 ms | 460 KB | Output is correct |
2 | Correct | 21 ms | 340 KB | Output is correct |
3 | Correct | 23 ms | 360 KB | Output is correct |
4 | Correct | 24 ms | 460 KB | Output is correct |
5 | Correct | 25 ms | 400 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 24 ms | 340 KB | Output is correct |
2 | Correct | 16 ms | 580 KB | Output is correct |
3 | Correct | 17 ms | 724 KB | Output is correct |
4 | Correct | 23 ms | 1020 KB | Output is correct |
5 | Correct | 14 ms | 1236 KB | Output is correct |
6 | Correct | 9 ms | 1504 KB | Output is correct |
7 | Correct | 16 ms | 1748 KB | Output is correct |
8 | Correct | 15 ms | 2064 KB | Output is correct |
9 | Correct | 16 ms | 2340 KB | Output is correct |
10 | Correct | 23 ms | 2504 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 22 ms | 368 KB | Output is correct |
3 | Correct | 19 ms | 596 KB | Output is correct |
4 | Correct | 23 ms | 984 KB | Output is correct |
5 | Correct | 20 ms | 1236 KB | Output is correct |
6 | Correct | 20 ms | 1652 KB | Output is correct |
7 | Correct | 9 ms | 1140 KB | Output is correct |
8 | Correct | 21 ms | 2088 KB | Output is correct |
9 | Correct | 15 ms | 2384 KB | Output is correct |
10 | Correct | 20 ms | 2692 KB | Output is correct |
11 | Correct | 24 ms | 3024 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 25 ms | 460 KB | Output is correct |
2 | Correct | 21 ms | 340 KB | Output is correct |
3 | Correct | 23 ms | 360 KB | Output is correct |
4 | Correct | 24 ms | 460 KB | Output is correct |
5 | Correct | 25 ms | 400 KB | Output is correct |
6 | Correct | 24 ms | 340 KB | Output is correct |
7 | Correct | 16 ms | 580 KB | Output is correct |
8 | Correct | 17 ms | 724 KB | Output is correct |
9 | Correct | 23 ms | 1020 KB | Output is correct |
10 | Correct | 14 ms | 1236 KB | Output is correct |
11 | Correct | 9 ms | 1504 KB | Output is correct |
12 | Correct | 16 ms | 1748 KB | Output is correct |
13 | Correct | 15 ms | 2064 KB | Output is correct |
14 | Correct | 16 ms | 2340 KB | Output is correct |
15 | Correct | 23 ms | 2504 KB | Output is correct |
16 | Correct | 1 ms | 212 KB | Output is correct |
17 | Correct | 22 ms | 368 KB | Output is correct |
18 | Correct | 19 ms | 596 KB | Output is correct |
19 | Correct | 23 ms | 984 KB | Output is correct |
20 | Correct | 20 ms | 1236 KB | Output is correct |
21 | Correct | 20 ms | 1652 KB | Output is correct |
22 | Correct | 9 ms | 1140 KB | Output is correct |
23 | Correct | 21 ms | 2088 KB | Output is correct |
24 | Correct | 15 ms | 2384 KB | Output is correct |
25 | Correct | 20 ms | 2692 KB | Output is correct |
26 | Correct | 24 ms | 3024 KB | Output is correct |
27 | Correct | 25 ms | 460 KB | Output is correct |
28 | Correct | 25 ms | 728 KB | Output is correct |
29 | Correct | 31 ms | 1036 KB | Output is correct |
30 | Correct | 24 ms | 1428 KB | Output is correct |
31 | Correct | 22 ms | 1724 KB | Output is correct |
32 | Correct | 18 ms | 1920 KB | Output is correct |
33 | Correct | 18 ms | 2192 KB | Output is correct |
34 | Correct | 21 ms | 2512 KB | Output is correct |
35 | Correct | 26 ms | 2876 KB | Output is correct |
36 | Correct | 36 ms | 3112 KB | Output is correct |