# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
641598 | christinelynn | Zagrade (COI20_zagrade) | C++17 | 882 ms | 1064 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 bupol __builtin_popcount
#define ll long long
#define fi first
#define se second
#define pb push_back
#define pu push
using namespace std;
const ll MAXN = 4e5+10;
const ll MAXS = 4010;
const ll INF = 1e9;
const ll MOD = 998244353;
const ll LOG = 60;
typedef pair<ll,ll> pii;
typedef pair<pii,ll> ipii;
vector <int> v;
char ans[MAXN];
int que(int x, int y){
cout << "? " << x << ' ' << y << endl;
int te; cin >> te; return te;
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n, q; cin >> n >> q;
for(int i=1; i<=n; i++){
if(v.empty()){
v.pb(i);
continue;
}
v.pb(i);
int siz = v.size()-1;
int te = que(v[siz-1], v[siz]);
if(te==1){
ans[v[siz-1]] = '('; ans[v[siz]] = ')';
v.pop_back(); v.pop_back();
}
}
for(int i=0; i<v.size()/2; i++) ans[v[i]] = ')';
for(int i=v.size()/2; i<v.size(); i++) ans[v[i]] = '(';
cout << "! ";
for(int i=1; i<=n; i++) cout << ans[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... |