# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
345450 |
2021-01-07T11:07:59 Z |
pggp |
Zagrade (COI20_zagrade) |
C++14 |
|
1 ms |
364 KB |
#include <bits/stdc++.h>
using namespace std;
int N, Q;
char output[250000];
int main(){
cin.tie(0);
cout.tie(0);
ios_base::sync_with_stdio(false);
for (int i = 0; i < N; ++i)
{
output[i] = '?';
}
cin >> N >> Q;
stack < int > last_non_valid;
for (int i = 0; i < N; ++i)
{
if(last_non_valid.empty()){
last_non_valid.push(i);
continue;
}
cout << "? " << last_non_valid.top() + 1 << " " << i + 1 << endl;
bool valid;
cin >> valid;
if(valid){
output[last_non_valid.top()] = '(';
output[i] = ')';
last_non_valid.pop();
}
else{
last_non_valid.push(i);
}
}
int s = last_non_valid.size();
for (int i = 0; i < s/2; ++i)
{
output[last_non_valid.top()] = '(';
last_non_valid.pop();
}
for (int i = s/2; i < s; ++i)
{
output[last_non_valid.top()] = ')';
last_non_valid.pop();
}
for (int i = 0; i < N; ++i)
{
cout << output[i];
}
cout << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Incorrect query () |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
364 KB |
Incorrect query )( |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Incorrect query (()) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Incorrect query ))(( |
2 |
Halted |
0 ms |
0 KB |
- |