#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
int n,q;
cin>>n>>q;
stack<int>isi;
char jwb[n+1];
for(int d=1;d<=n;d++){
if(isi.empty()){
isi.push(d);
jwb[d]='(';
}
else{
cout<<"? "<<isi.top()<<" "<<d<<endl;
int w;
cin>>w;
if(w==0){
isi.push(d);
jwb[d]='(';
}
else{
isi.pop();
jwb[d]=')';
}
}
}
int ganti=isi.size()/2;
while(!isi.empty()){
if(ganti==0){
jwb[isi.top()]='(';
}
else{
ganti--;
}
isi.pop();
}
cout<<"! ";
for(int d=1;d<=n;d++){
cout<<jwb[d];
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
3 ms |
344 KB |
Output is correct |
3 |
Correct |
5 ms |
344 KB |
Output is correct |
4 |
Correct |
3 ms |
344 KB |
Output is correct |
5 |
Correct |
5 ms |
344 KB |
Output is correct |
6 |
Correct |
4 ms |
344 KB |
Output is correct |
7 |
Correct |
4 ms |
344 KB |
Output is correct |
8 |
Correct |
4 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Mismatch at position 1. Expected ), found ( |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
214 ms |
344 KB |
Output is correct |
3 |
Correct |
537 ms |
344 KB |
Output is correct |
4 |
Correct |
530 ms |
344 KB |
Output is correct |
5 |
Correct |
548 ms |
344 KB |
Output is correct |
6 |
Correct |
557 ms |
344 KB |
Output is correct |
7 |
Correct |
529 ms |
1560 KB |
Output is correct |
8 |
Correct |
565 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Mismatch at position 1. Expected ), found ( |
2 |
Halted |
0 ms |
0 KB |
- |