# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
773476 | vjudge1 | Zagrade (COI20_zagrade) | C++17 | 835 ms | 900 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;
void f(){
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
}
int qu(int a, int b){
cout<<"? "<<a+1<<" "<<b+1<<endl;
cin>>a; return a;
}
void solve(){
int n, m; cin >> n >> m;
string s;
stack<int> q;
for(int i=0; i < n; i++) s+='.';
q.push(0);
for(int i=1; i<n; i++){
if(!q.size()){
q.push(i);
}
else if(qu(q.top(), i)){
s[q.top()]='(';
s[i]=')';
q.pop();
}
else{
q.push(i);
}
}
int p=q.size()/2;
while(p--){
s[q.top()]='(';
q.pop();
}
while(q.size()){
s[q.top()]=')';
q.pop();
}
cout<<"! "<<s<<endl;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
solve();
}
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... |