# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
773515 | vjudge1 | Zagrade (COI20_zagrade) | C++17 | 859 ms | 1200 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>
using namespace std;
typedef long long lo;
#define fi first
#define se second
#define endl "\n"
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)
const lo inf = 1000000000;
const lo li = 500005;
const lo mod = 1000000007;
int n,m,a[li],k,flag,t;
int cev;
string s;
vector<int> v;
char b[li];
inline int in(){
int x;
cin>>x;
return x;
}
int main(void){
scanf("%d %d",&n,&t);
FOR b[i]='_';
stack<int> st;
st.push(1);
for(int i=1;i<n;i++){
if(st.size()==0){st.push(i+1);continue;}
printf("? %d %d\n",st.top(),i+1);
fflush(stdout);
scanf("%d",&a[i]);
//~ cout<<st.top()<<" :: "<<i+1<<endl;
if(a[i]==1){b[st.top()]='(';b[i+1]=')';st.pop();}
else st.push(i+1);
}
int emp=0;
FOR{
if(b[i]=='_'){
emp++;
}
}
int tmp=0;
FOR{
if(b[i]=='_' && tmp<emp/2){tmp++;b[i]=')';}
else if(b[i]=='_') b[i]='(';
}
printf("! ");
FOR printf("%c",b[i]);
printf("\n");
fflush(stdout);
return 0;
}
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... |