# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1034296 | Luvidi | Zagrade (COI20_zagrade) | C++17 | 586 ms | 1744 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll, ll>
#define pii pair<int, int>
#define fs first
#define sc second
#define pb push_back
void solve() {
int n,q;
cin>>n>>q;
string ans;
for(int i=1;i<=n;i++)ans+='.';
vector<int> v;
for(int i=1;i<=n;i++){
v.pb(i);
if(v.size()==1)continue;
int x=v.size();
cout<<"? "<<v[x-2]<<' '<<v[x-1]<<endl;
bool b;
cin>>b;
if(b){
ans[v[x-2]-1]='(';
ans[v[x-1]-1]=')';
v.pop_back();
v.pop_back();
}
}
for(int i=0;i<v.size()/2;i++)ans[v[i]-1]=')';
for(int i=v.size()/2;i<v.size();i++)ans[v[i]-1]='(';
cout<<"! "<<ans;
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
solve();
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |