# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
559792 | 2022-05-10T15:27:20 Z | A_D | Zagrade (COI20_zagrade) | C++14 | 1489 ms | 376 KB |
#include <bits/stdc++.h> #define int long long #define ii pair<int,int> #define F first #define S second using namespace std; void solve() { int n,q; cin>>n>>q; string s(n,'0'); int h=n; for(int i=0;i<n;i++){ for(int j=i+1;j<n;j+=2){ if(s[i]!='0'||s[j]!='0')continue; if(i>=n||j>=n){ cout<<"! "<<s<<endl; return; } cout<<"? "<<i+1<<" "<<j+1<<endl; int x; cin>>x; if(x==1){ h-=2; s[i]='('; s[j]=')'; } } } h/=2; for(int i=0;i<n;i++){ if(s[i]=='0'){ if(h>0){ s[i]=')'; } else{ s[i]='('; } h--; } } cout<<"! "<<s<<endl; } main() { /* ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); //*/ int t=1; // cin>>t; while(t--){ solve(); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 208 KB | Output is correct |
2 | Correct | 5 ms | 208 KB | Output is correct |
3 | Correct | 24 ms | 208 KB | Output is correct |
4 | Correct | 31 ms | 208 KB | Output is correct |
5 | Correct | 59 ms | 208 KB | Output is correct |
6 | Correct | 88 ms | 208 KB | Output is correct |
7 | Correct | 894 ms | 208 KB | Output is correct |
8 | Correct | 50 ms | 208 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 208 KB | Output is correct |
2 | Runtime error | 1467 ms | 280 KB | Execution killed with signal 13 |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 208 KB | Output is correct |
2 | Correct | 1489 ms | 376 KB | Output is correct |
3 | Runtime error | 654 ms | 376 KB | Execution killed with signal 13 |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 208 KB | Incorrect |
2 | Halted | 0 ms | 0 KB | - |