#include <bits/stdc++.h>
using namespace std;
const int M = 1e5 + 1;
char ans[M];
void solve(int a,int b)
{
if (a+1==b)
{
ans[a]='(';
ans[b]=')';
return;
}
cout<<"? "<<a+1<<' '<<b-1<<endl;
bool v;
cin>>v;
if (v)
{
ans[a]='(';
ans[b]=')';
solve(a+1,b-1);
return;
}
for (int i=a+1;i<b;i++)
{
cout<<"? "<<a<<' '<<i<<endl;
cin>>v;
if (v)
{
solve(a,i);
solve(i+1,b);
return;
}
}
}
int main()
{
int n,q;
cin>>n>>q;
solve(1,n);
cout<<"! ";
for (int i=1;i<=n;i++)
cout<<ans[i];
cout<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
4 ms |
344 KB |
Output is correct |
3 |
Correct |
27 ms |
348 KB |
Output is correct |
4 |
Correct |
27 ms |
344 KB |
Output is correct |
5 |
Correct |
26 ms |
344 KB |
Output is correct |
6 |
Correct |
16 ms |
344 KB |
Output is correct |
7 |
Correct |
3 ms |
344 KB |
Output is correct |
8 |
Correct |
18 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 |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
583 ms |
5232 KB |
Output is correct |
3 |
Runtime error |
549 ms |
672 KB |
Execution killed with signal 13 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Mismatch at position 1. Expected ), found |
2 |
Halted |
0 ms |
0 KB |
- |