# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
780824 | kebine | Zagrade (COI20_zagrade) | C++17 | 807 ms | 1540 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define LL long long
using namespace std;
LL jawab;
void tanya(LL x,LL y)
{
cout<<"? "<<x<<" "<<y<<endl;
cin>>jawab;
}
int main()
{
LL n,q;
scanf("%lld %lld",&n,&q);
vector<LL>v;
char arr[n+5];
for(LL a=1;a<=n;a++)
{
arr[a]='*';
}
LL buka=0,tutup=0;
for(LL a=1;a<=n;a++)
{
if(v.size()==0)
{
v.push_back(a);
continue;
}
tanya(v[v.size()-1],a);
if(!jawab)
{
v.push_back(a);
}
else
{
arr[v[v.size()-1]]='(';
arr[a]=')';
tutup++;
v.pop_back();
}
}
LL bagi=n/2;
for(LL a=1;a<=n;a++)
{
// printf("%lld %lld %lld\n",buka,tutup,bagi);
if(arr[a]=='*')
{
if(tutup<bagi)
{
arr[a]=')';
tutup++;
}
else arr[a]='(';
}
}
cout<<"! ";
for(LL a=1;a<=n;a++)cout<<arr[a];
cout<<endl;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |