This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//#pragma GCC optimize("Ofast","O3","unroll-loops")
//#pragma GCC target("avx2")
#include<bits/stdc++.h>
using namespace std;
//#define double long double
#define int long long
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define rz resize
#define pb emplace_back
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define x first
#define y second
#define ACorz ios_base::sync_with_stdio(false);cin.tie(0);
//#define endl '\n'
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
const int INF=1e9,INF2=2e9;
const int mod1=1e9+7;
const int mod=998244353;
const int N=5005;
const int K=45000;
const int M=5000;
int ask(int a,int b){
cout<<"? "<<a+1<<' '<<b+1<<endl;
int p;cin>>p;
return p;
}
int32_t main(){
//ACorz;
int n;cin>>n;
int q;cin>>q;
vector<int> v;
string s(n,'0');
for(int i=0;i<n;i++){
if(v.size()==0){
v.push_back(i);
continue;
}
if(ask(v.back(),i)){
s[v.back()]='(';
s[i]=')';
v.pop_back();
}
else{
v.push_back(i);
}
}
int x=v.size()/2;
for(int i=0;i<x;i++){
s[v.back()]='(';
v.pop_back();
}
for(int i=0;i<x;i++){
s[v.back()]=')';
v.pop_back();
}
cout<<"! "<<s<<endl;
return 0;
}
# | 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... |