# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1003775 | vjudge1 | Zagrade (COI20_zagrade) | C++17 | 620 ms | 1752 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 query( int a, int b ){
cout << "? " << a << " " << b << endl;
int x; cin >> x; return x;
}
int main(){
int n, q; cin >> n >> q;
stack<int> pilha;
vector<int> resp(n + 1);
for( int i = 1; i <= n; i++ ){
if( pilha.empty() ){
pilha.push(i);
continue;
}
if( query( pilha.top(), i ) ){
resp[i] = -1;
resp[pilha.top()] = 1;
pilha.pop();
}
else pilha.push(i);
}
int tam = pilha.size()/2;
while(tam--){ resp[pilha.top()] = 1; pilha.pop(); }
while(!pilha.empty()){ resp[pilha.top()] = -1; pilha.pop(); }
cout << "! ";
for( int i = 1; i <= n; i++ ) cout << (( resp[i] == 1 ) ? "(" : ")" ); 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... |