# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
706427 | 2023-03-06T14:41:50 Z | vjudge1 | Zagrade (COI20_zagrade) | C++17 | 920 ms | 936 KB |
#include <bits/stdc++.h> using namespace std; // #define int long long // #define endl '\n' #define F first #define S second #define pb push_back #define all(a) a.begin(),a.end() const int N=4e3; const int off=1<<20; const int MOD=1e9+7; signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n,q; cin >> n >> q; int mns=1; string s; int cnt=n/2; stack<int>stck; stck.push(1); for(int i=0;i<n;i++)s+='?'; for(int i=2;i<=n;i++){ if(stck.empty()){ stck.push(i); continue; } cout.flush()<<"? "<<stck.top()<<' '<<i<<endl; int ans; cin >> ans; if(ans){ s[stck.top()-1]='('; s[i-1]=')'; stck.pop(); cnt--; } else { stck.push(i); mns=1; } } int l=cnt,r=cnt; for(int i=0;i<n;i++){ if(s[i]=='?'){ if(l){ s[i]=')'; l--; } else{ s[i]='('; r--; } } } cout.flush()<<"! "<<s<<endl; }
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 | 13 ms | 208 KB | Output is correct |
4 | Correct | 8 ms | 208 KB | Output is correct |
5 | Correct | 8 ms | 208 KB | Output is correct |
6 | Correct | 10 ms | 208 KB | Output is correct |
7 | Correct | 11 ms | 372 KB | Output is correct |
8 | Correct | 6 ms | 248 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 256 KB | Output is correct |
2 | Correct | 13 ms | 256 KB | Output is correct |
3 | Correct | 11 ms | 256 KB | Output is correct |
4 | Correct | 4 ms | 320 KB | Output is correct |
5 | Correct | 10 ms | 208 KB | Output is correct |
6 | Correct | 11 ms | 208 KB | Output is correct |
7 | Correct | 10 ms | 208 KB | Output is correct |
8 | Correct | 9 ms | 208 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 208 KB | Output is correct |
2 | Correct | 494 ms | 520 KB | Output is correct |
3 | Correct | 852 ms | 520 KB | Output is correct |
4 | Correct | 748 ms | 520 KB | Output is correct |
5 | Correct | 766 ms | 580 KB | Output is correct |
6 | Correct | 920 ms | 524 KB | Output is correct |
7 | Correct | 666 ms | 836 KB | Output is correct |
8 | Correct | 874 ms | 520 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 563 ms | 936 KB | Output is correct |
3 | Correct | 679 ms | 596 KB | Output is correct |
4 | Correct | 883 ms | 564 KB | Output is correct |
5 | Correct | 848 ms | 528 KB | Output is correct |
6 | Correct | 847 ms | 892 KB | Output is correct |
7 | Correct | 774 ms | 648 KB | Output is correct |
8 | Correct | 749 ms | 516 KB | Output is correct |