# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
546245 | 2022-04-06T19:05:38 Z | yutabi | Zagrade (COI20_zagrade) | C++14 | 707 ms | 4064 KB |
#include <bits/stdc++.h> using namespace std; struct pos { int ptr=0; pos* l=NULL; pos* r=NULL; }; pos* bas=new pos; void rm(pos* nd) { if(nd->l!=NULL) { nd->l->r=nd->r; } if(nd->r!=NULL) { nd->r->l=nd->l; } if(nd==bas && nd->r!=NULL) { bas=nd->r; } } int n; int q; int ans[100007]; int k; int main() { scanf("%d %d",&n,&q); pos* curr=bas; for(int i=1;i<n;i++) { pos* nw=new pos; nw->ptr=i; nw->l=curr; curr->r=nw; curr=nw; } curr=bas; for(int i=0;i<n;i++) { if(curr->l!=NULL) { printf("? %d %d\n",(curr->l->ptr)+1,(curr->ptr)+1); fflush(stdout); int a; scanf(" %d",&a); if(a==1) { ans[curr->l->ptr]=1; ans[curr->ptr]=2; rm(curr->l); rm(curr); k+=2; } else if(a!=0) { return 0; } } curr=curr->r; } curr=bas; for(int i=0;i<n-k;i++) { if(i*2<n-k) { ans[curr->ptr]=2; } else { ans[curr->ptr]=1; } curr=curr->r; } printf("! "); for(int i=0;i<n;i++) { if(ans[i]==1) { printf("("); } if(ans[i]==2) { printf(")"); } } fflush(stdout); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 296 KB | Output is correct |
2 | Correct | 4 ms | 336 KB | Output is correct |
3 | Correct | 7 ms | 340 KB | Output is correct |
4 | Correct | 9 ms | 336 KB | Output is correct |
5 | Correct | 7 ms | 336 KB | Output is correct |
6 | Correct | 8 ms | 336 KB | Output is correct |
7 | Correct | 8 ms | 336 KB | Output is correct |
8 | Correct | 8 ms | 332 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 208 KB | Output is correct |
2 | Correct | 7 ms | 208 KB | Output is correct |
3 | Correct | 7 ms | 340 KB | Output is correct |
4 | Correct | 8 ms | 336 KB | Output is correct |
5 | Correct | 7 ms | 336 KB | Output is correct |
6 | Correct | 8 ms | 336 KB | Output is correct |
7 | Correct | 8 ms | 336 KB | Output is correct |
8 | Correct | 7 ms | 260 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 208 KB | Output is correct |
2 | Correct | 387 ms | 4008 KB | Output is correct |
3 | Correct | 425 ms | 3952 KB | Output is correct |
4 | Correct | 562 ms | 4064 KB | Output is correct |
5 | Correct | 559 ms | 3864 KB | Output is correct |
6 | Correct | 462 ms | 3836 KB | Output is correct |
7 | Correct | 604 ms | 3964 KB | Output is correct |
8 | Correct | 567 ms | 3816 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 208 KB | Output is correct |
2 | Correct | 692 ms | 3804 KB | Output is correct |
3 | Correct | 673 ms | 4004 KB | Output is correct |
4 | Correct | 538 ms | 3936 KB | Output is correct |
5 | Correct | 692 ms | 3904 KB | Output is correct |
6 | Correct | 581 ms | 3920 KB | Output is correct |
7 | Correct | 673 ms | 3860 KB | Output is correct |
8 | Correct | 707 ms | 3972 KB | Output is correct |