#include <bits/stdc++.h>
using namespace std;
#define int long long
#define OYY 10000000005
#define mod 1000000007
#define endl '\n'
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);
char dizi[100005];
vector <int> q;
bool kes[100005];
vector <pair<pair<int,int>,int>> de;
int ko=0;
int sor(int x,int y){
cout<<'?'<<' '<<x<<' '<<y;
cout<<endl;
int m;cin>>m;
cout<<endl;
de.push_back({{x,y},m});
return m;
}
int32_t main(){
faster
int n,k;cin>>n>>k;
//cout<<endl;
dizi[1]='(';
q.push_back(1);
for(int i=2;i<=n;i++){
if(q.size() && sor(q.back(),i)){
dizi[i]=')';
ko+=1;
q.pop_back();
}
else{
dizi[i]='(';
q.push_back(i);
}
}
k-=n-1;
while(k>=0 && q.size()){
int i;
if(q.size())i=q[0];
else i=2;
for(;i<=n;i++){
if(q.size() && sor(q.back(),i)){
dizi[i]=')';
//kes[i]=1;
ko+=1;
q.pop_back();
}
else{
dizi[i]='(';
q.push_back(i);
}
}
k-=n-1;
}
/*int gec=q.size()/2;
for(int i=0;i<=gec-1;i++){
dizi[q[i]]=')';
}*/
cout<<'!';
for(int i=1;i<=n;i++)cout<<' '<<dizi[i];
cout<<endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1 ms |
208 KB |
Time limit exceeded (wall clock) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1 ms |
208 KB |
Time limit exceeded (wall clock) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1 ms |
208 KB |
Time limit exceeded (wall clock) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1 ms |
208 KB |
Time limit exceeded (wall clock) |
2 |
Halted |
0 ms |
0 KB |
- |