# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
774215 | vjudge1 | Zagrade (COI20_zagrade) | C++17 | 659 ms | 668 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;
#define lalala ios_base::sync_with_stdio(false);cin.tie(NULL);
//#define endl "\n"
#define ll long long
#define N 200005
#define pb push_back
int main(){
lalala;
int n,q;cin>>n>>q;
stack<int> s;
char str[n+1];
for(int i=1;i<=n;i++){
if(s.size()){
int a=s.top();
cout<<"? "<<a<<" "<<i<<endl;
int x;cin>>x;
if(x==1){
str[i]=')';
str[a]='(';
s.pop();
}
else{
s.push(i);
}
}
else{
s.push(i);
}
}
for(int i=1;i<=s.size()/2;i++){
str[s.top()]='(';
s.pop();
}
for(int i=1;i<=s.size();i++){
str[s.top()]=')';
s.pop();
}
cout<<"! ";
for(int i=1;i<=n;i++)cout<<str[i];
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... |