#include <bits/stdc++.h>
#define int long long
using namespace std;
void ask(int a,int b)
{
cout<<"? "<<a<<" "<<b<<endl;
}
void solve()
{
int n,q,x;
cin>>n>>q;
string s(n+1,'0');
s[1]='(';
s[n]=')';
int l=2,r=n-1;
while(l<=r){
ask(l,r);
cin>>x;
if(x==1){
s[l]='(';
s[r]=')';
l++;
r--;
}
else{
if(l+1==r){
s[l]=')';
s[r]='(';
l++;
r--;
}
else{
ask(l-1,l);
cin>>x;
if(x==0){
s[l]=')';
l++;
}
else{
s[r]=')';
r--;
}
}
}
}
string ans;
for(int i=1;i<=n;i++){
ans+=s[i];
}
cout<<"! "<<ans<<endl;
}
main()
{
int t=1;
// cin>>t;
while(t--)solve();
}
Compilation message
zagrade.cpp:52:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
52 | main()
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Incorrect |
21 ms |
200 KB |
Mismatch at position 5. Expected (, found ) |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
200 KB |
Mismatch at position 1. Expected ), found ( |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Runtime error |
863 ms |
328 KB |
Execution killed with signal 13 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
200 KB |
Mismatch at position 1. Expected ), found ( |
2 |
Halted |
0 ms |
0 KB |
- |