# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
930030 | MuntherCarrot | Zagrade (COI20_zagrade) | C++14 | 541 ms | 1368 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 ll long long
// #define endl '\n'
#define all(x) x.begin(),x.end()
const int MOD = 1e9 + 7, SZ = 1e5 + 100, MX = 1e9;
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n, q;
cin >> n >> q;
int p[n+2], s[n+1]={}, x = n/2;
for(int i=1;i<=n;i++)
p[i] = i-1;
for(int i=1;i<=n;i++){
if(p[i] == 0)
continue;
int ans;
cout.flush() << "? " << p[i] << ' ' << i << endl;
cin >> ans;
if(ans == 1){
s[i] = 2;
s[p[i]] = 1;
x--;
p[i+1] = p[p[i]];
}
}
int a = x, b = x;
for(int i=1;i<=n;i++){
if(s[i])
continue;
if(a){
a--;
s[i] = 2;
}
else
s[i] = 1;
}
cout.flush() << "! ";
for(int i=1;i<=n;i++)
cout.flush() << (s[i] == 2 ? ')' : '(');
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... |