# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
748482 | mariowong | Zagrade (COI20_zagrade) | C++14 | 1078 ms | 916 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;
int n,q,ct,x,l,r;
char s[100005];
stack <int> st;
int main(){
scanf("%d%d",&n,&q);
st.push(1);
for (int i=2;i<=n;i++){
if (!st.empty()){
printf("? %d %d\n",st.top(),i);
fflush(stdout);
scanf("%d",&x);
if (x == 1){
s[st.top()]='(';
s[i]=')';
st.pop();
ct++;
}
else
st.push(i);
}
else
st.push(i);
}
printf("! ");
for (int i=1;i<=n;i++){
if (ct < n/2 && s[i] != ')' && s[i] != '('){
s[i]=')';
ct++;
}
else
if (s[i] != '(' && s[i] != ')')
s[i]='(';
}
for (int i=1;i<=n;i++){
printf("%c",s[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... |