#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
//#define int long long
int n,q;
char c[1000005];
vector <int> v;
bool b1;
bool query(int l,int r){
cout<<"? "<<l<<" "<<r<<endl;
bool b2;
cin>>b2;
return b2;
}
int main(){
cin>>n>>q;
// v.pb(1\);
for(int i=1;i<=n;i++){
v.pb(i);
if(v.size()<2){
continue;
}
b1=query(v[v.size()-2],v[v.size()-1]);
if(b1){
c[v[v.size()-2]]='(';
c[v[v.size()-1]]=')';
v.pop_back();
v.pop_back();
}
}
if(v.size()){
cout<<"! ";
cout<<-1<<endl;
}else{
cout<<"! ";
for(int i=1;i<=n;i++){
cout<<c[i];
}
cout<<endl;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
9 ms |
336 KB |
Output is correct |
3 |
Correct |
17 ms |
336 KB |
Output is correct |
4 |
Correct |
13 ms |
504 KB |
Output is correct |
5 |
Correct |
14 ms |
336 KB |
Output is correct |
6 |
Correct |
18 ms |
336 KB |
Output is correct |
7 |
Correct |
11 ms |
336 KB |
Output is correct |
8 |
Correct |
15 ms |
504 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Mismatch at position 1. Expected ), found - |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
909 ms |
1244 KB |
Output is correct |
3 |
Correct |
1884 ms |
1032 KB |
Output is correct |
4 |
Correct |
1905 ms |
1032 KB |
Output is correct |
5 |
Correct |
1885 ms |
1016 KB |
Output is correct |
6 |
Correct |
1987 ms |
1008 KB |
Output is correct |
7 |
Correct |
1879 ms |
1592 KB |
Output is correct |
8 |
Correct |
1866 ms |
1032 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Answer length should be 4, but it is 2 |
2 |
Halted |
0 ms |
0 KB |
- |