#include <bits/stdc++.h>
using namespace std;
int main (){
ios::sync_with_stdio(0);
cin.tie(0);
int n,q;
cin>>n;
cin>>q;
string s="";
s=s+'(';
int p=1;
vector <int> v;
v.push_back(1);
for (int i=1;i<n;i++){
p=v[v.size()-1];
cout<<"? "<<p<<" "<<i+1<<endl;
bool ans;
cin>>ans;
if (ans==0){
s=s+'(';
v.push_back(i+1);
}
if (ans==1){
s=s+')';
v.pop_back();
if (v.size()==0 and i<n-1){
s=s+'(';
v.push_back(i+2);
i++;
}
}
}
cout<<"! "<<s;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
6 ms |
328 KB |
Output is correct |
3 |
Correct |
9 ms |
328 KB |
Output is correct |
4 |
Correct |
13 ms |
328 KB |
Output is correct |
5 |
Correct |
13 ms |
328 KB |
Output is correct |
6 |
Correct |
10 ms |
328 KB |
Output is correct |
7 |
Correct |
10 ms |
448 KB |
Output is correct |
8 |
Correct |
11 ms |
328 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
200 KB |
Mismatch at position 1. Expected ), found ( |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
1192 ms |
984 KB |
Output is correct |
3 |
Correct |
1635 ms |
1052 KB |
Output is correct |
4 |
Correct |
1461 ms |
988 KB |
Output is correct |
5 |
Correct |
1520 ms |
960 KB |
Output is correct |
6 |
Correct |
1511 ms |
984 KB |
Output is correct |
7 |
Correct |
1594 ms |
1152 KB |
Output is correct |
8 |
Correct |
1816 ms |
1864 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
200 KB |
Mismatch at position 1. Expected ), found ( |
2 |
Halted |
0 ms |
0 KB |
- |