# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
390838 |
2021-04-17T06:28:14 Z |
A_D |
Zagrade (COI20_zagrade) |
C++14 |
|
876 ms |
284 KB |
#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==1){
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()
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Incorrect |
18 ms |
200 KB |
Mismatch at position 503. Expected (, found ) |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
200 KB |
Mismatch at position 1. Expected ), found ( |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Runtime error |
876 ms |
284 KB |
Execution killed with signal 13 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
200 KB |
Mismatch at position 1. Expected ), found ( |
2 |
Halted |
0 ms |
0 KB |
- |