# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
411857 | 2021-05-26T06:55:37 Z | 조영욱(#7630) | Zagrade (COI20_zagrade) | C++17 | 1948 ms | 2432 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); for(int i=1;i<=n;i++) { for(int j=i+1;j<=n;j+=2) { printf("? %d %d\n",i,j); fflush(stdout); scanf("%d",&arr[i][j]); } } for(int sz=n;sz>0;sz-=2) { for(int i=1;i<=n-sz+1;i++) { if (str[i]==0) { 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 | 256 KB | Output is correct |
2 | Runtime error | 1948 ms | 2432 KB | Execution killed with signal 13 |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 200 KB | Mismatch at position 1. Expected ), found ( |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 200 KB | Incorrect |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 200 KB | Incorrect |
2 | Halted | 0 ms | 0 KB | - |