#include <bits/stdc++.h>
using namespace std;
#define int long long
//#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
char dizi[100005];
vector <string> x;
vector <int> q;
int sor(int x,int y){
cout<<"? "<<x<<" "<<y;
cout<<endl;
int m;cin>>m;
return m;
}
int32_t main(){
// faster
q.clear();
int n,k;
cin>>n>>k;
dizi[1]='(';
q.push_back(1);
for(int i=2;i<=n;i++){
if(q.size() && sor(q.back(),i)){
dizi[i]=')';
q.pop_back();
}
else{
dizi[i]='(';
q.push_back(i);
}
}
int gc=q.size()/2;
for(int i=0;i<=gc-1;i++){
dizi[q[i]]=')';
}
cout<<"! ";
for(int i=1;i<=n;i++)cout<<dizi[i];
cout<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
3 ms |
208 KB |
Output is correct |
3 |
Correct |
9 ms |
336 KB |
Output is correct |
4 |
Correct |
9 ms |
208 KB |
Output is correct |
5 |
Correct |
8 ms |
208 KB |
Output is correct |
6 |
Correct |
6 ms |
208 KB |
Output is correct |
7 |
Correct |
8 ms |
308 KB |
Output is correct |
8 |
Correct |
6 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
10 ms |
312 KB |
Output is correct |
3 |
Correct |
9 ms |
208 KB |
Output is correct |
4 |
Correct |
6 ms |
312 KB |
Output is correct |
5 |
Correct |
7 ms |
208 KB |
Output is correct |
6 |
Correct |
5 ms |
208 KB |
Output is correct |
7 |
Correct |
9 ms |
312 KB |
Output is correct |
8 |
Correct |
8 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
436 ms |
380 KB |
Output is correct |
3 |
Correct |
823 ms |
448 KB |
Output is correct |
4 |
Correct |
670 ms |
360 KB |
Output is correct |
5 |
Correct |
601 ms |
456 KB |
Output is correct |
6 |
Correct |
472 ms |
384 KB |
Output is correct |
7 |
Correct |
475 ms |
1196 KB |
Output is correct |
8 |
Correct |
717 ms |
472 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
494 ms |
1440 KB |
Output is correct |
3 |
Correct |
565 ms |
820 KB |
Output is correct |
4 |
Correct |
752 ms |
920 KB |
Output is correct |
5 |
Correct |
637 ms |
756 KB |
Output is correct |
6 |
Correct |
684 ms |
1008 KB |
Output is correct |
7 |
Correct |
791 ms |
732 KB |
Output is correct |
8 |
Correct |
608 ms |
360 KB |
Output is correct |