# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1004303 |
2024-06-21T07:30:21 Z |
vjudge1 |
Zagrade (COI20_zagrade) |
C++17 |
|
584 ms |
4116 KB |
#include <bits/stdc++.h>
using namespace std;
const int M = 1e5 + 1;
char ans[M];
bool que(int x,int y)
{
cout<<"? "<<x<<' '<<y<<endl;
bool b;
cin>>b;
return b;
}
void solve(int a,int b)
{
if (a>=b)
return;
if (a+1==b)
{
ans[a]='(';
ans[b]=')';
return;
}
bool v=que(a+1,b-1);
if (v)
{
ans[a]='(';
ans[b]=')';
solve(a+1,b-1);
return;
}
for (int i=b-2;i>a;i-=2)
{
v=que(a,i);
if (v)
{
ans[i+1]='(';
ans[b]=')';
solve(a,i);
solve(i+2,b-1);
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;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
4 ms |
444 KB |
Output is correct |
3 |
Correct |
7 ms |
344 KB |
Output is correct |
4 |
Correct |
8 ms |
344 KB |
Output is correct |
5 |
Correct |
11 ms |
344 KB |
Output is correct |
6 |
Correct |
9 ms |
344 KB |
Output is correct |
7 |
Correct |
2 ms |
344 KB |
Output is correct |
8 |
Correct |
7 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Mismatch at position 1. Expected ), found ( |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
576 ms |
4116 KB |
Output is correct |
3 |
Runtime error |
584 ms |
960 KB |
Execution killed with signal 13 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Mismatch at position 1. Expected ), found |
2 |
Halted |
0 ms |
0 KB |
- |