# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
411867 | 2021-05-26T07:19:00 Z | 조영욱(#7630) | Zagrade (COI20_zagrade) | C++17 | 1915 ms | 2468 KB |
#include <bits/stdc++.h> using namespace std; char str[1002]; int arr[1001][1001]; void track(int i,int j) { if (j==i+1) { str[i]='('; str[j]=')'; return; } for(int k=i+2;k<j;k+=2) { if (arr[i][k-1]==1&&arr[k][j]==1) { track(i,k-1); track(k,j); return; } } str[i]='('; str[j]=')'; track(i+1,j-1); return; } int main(void) { int n,q; scanf("%d %d",&n,&q); int cnt=0; for(int i=1;i<=n;i++) { for(int j=i+1;j<=n;j+=2) { if (cnt==q) { printf("! \n"); fflush(stdout); return 0; } printf("? %d %d\n",i,j); fflush(stdout); scanf("%d",&arr[i][j]); cnt++; } } for(int sz=n;sz>0;sz-=2) { for(int i=1;i<=n-sz+1;i++) { if (str[i]==0&&arr[i][i+sz-1]==1) { track(i,i+sz-1); } } } int rleft=n/2; for(int i=1;i<=n;i++) { if (str[i]==')') { rleft--; } } for(int i=1;i<=n;i++) { if (str[i]==0) { if (rleft!=0) { rleft--; str[i]=')'; } else { str[i]='('; } } } printf("! %s\n",str+1); fflush(stdout); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 200 KB | Output is correct |
2 | Runtime error | 1915 ms | 2400 KB | Execution killed with signal 13 |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 200 KB | Output is correct |
2 | Runtime error | 1450 ms | 2468 KB | Execution killed with signal 13 |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 200 KB | Unexpected end of file - token expected |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 200 KB | Unexpected end of file - token expected |
2 | Halted | 0 ms | 0 KB | - |