# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
640287 |
2022-09-14T05:51:49 Z |
kebine |
Zagrade (COI20_zagrade) |
C++17 |
|
1006 ms |
1504 KB |
#include <bits/stdc++.h>
using namespace std;
#define nyahalo ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define otsumiko exit(0);
#define mikodanye priority_queue<pair<long long, long long>, vector<pair<long long, long long> >, greater<pair<long long, long long> > >
#define mikochi priority_queue<long long, vector<long long>, greater<long long> >
long long n, q, x, a[100069], pi, np, ng;
stack<long long> stk;
int main() {
nyahalo
long long i, j;
cin >> n >> q;
np = n/2;
ng = n/2;
for (i=1; i<=n; i++) {
a[i] = 0;
}
if(q == n-1) {
a[1] = 1;
stk.push(1);
for (i=2; i<=n; i++) {
if (stk.empty()) {
stk.push(i);
a[i] = 1;
} else {
pi = stk.top();
cout << "? " << pi << " " << i << "\n" << flush;
cin >> x;
if (x == 1) {
a[i] = -1;
stk.pop();
} else {
a[i] = 1;
stk.push(i);
}
}
}
cout << "! ";
for (i=1; i<=n; i++) {
if (a[i] == 1) {
cout << "(";
} else {
cout << ")";
}
}
cout << "\n" << flush;
otsumiko
}
for (i=2; i<=n; i+=2) {
for (j=1; j<=n-i+1; j++) {
cout << "? " << j << " " << j+i-1 << "\n" << flush;;
cin >> x;
if (x == 1) {
if (a[j] == 0) {
np--;
}
a[j] = 1;
if (a[j+i-1] == 0) {
ng--;
}
a[j+i-1] = -1;
}
}
}
for (i=1; i<=n; i++) {
if (a[i] == 0) {
if (ng>0) {
a[i] = -1;
ng--;
} else {
a[i] = 1;
np--;
}
}
}
cout << "! ";
for (i=1; i<=n; i++) {
if (a[i] == 1) {
cout << "(";
} else {
cout << ")";
}
}
cout << "\n";
otsumiko
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Runtime error |
916 ms |
316 KB |
Execution killed with signal 13 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
208 KB |
Mismatch at position 1. Expected ), found ( |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
414 ms |
1084 KB |
Output is correct |
3 |
Correct |
738 ms |
1080 KB |
Output is correct |
4 |
Correct |
688 ms |
1084 KB |
Output is correct |
5 |
Correct |
805 ms |
1104 KB |
Output is correct |
6 |
Correct |
1006 ms |
1104 KB |
Output is correct |
7 |
Correct |
817 ms |
1504 KB |
Output is correct |
8 |
Correct |
795 ms |
1084 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
208 KB |
Mismatch at position 1. Expected ), found ( |
2 |
Halted |
0 ms |
0 KB |
- |