#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
const int MAX = 1e5 + 10;
int n, q;
int x;
vector <int> v;
int arr[MAX];
int main() {
cin >> n >> q;
v.push_back(1);
for (int i = 2; i <= n; i++) {
if (v.size() == 0) {
v.push_back(i);
continue;
}
cout << "? " << v.back() << " " << i << endl;
cin >> x;
if (x == 0) {
v.push_back(i);
}
else {
arr[i] = 2;
arr[v.back()] = 1;
v.pop_back();
}
}
cout << "! ";
for (int i = 1; i <= n; i++) {
if (arr[i] == 1) {
cout << "(";
}
else {
cout << ")";
}
}
cout << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
4 ms |
200 KB |
Output is correct |
3 |
Correct |
12 ms |
300 KB |
Output is correct |
4 |
Correct |
13 ms |
360 KB |
Output is correct |
5 |
Correct |
12 ms |
300 KB |
Output is correct |
6 |
Correct |
10 ms |
200 KB |
Output is correct |
7 |
Correct |
13 ms |
304 KB |
Output is correct |
8 |
Correct |
9 ms |
200 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
200 KB |
Mismatch at position 2. Expected (, found ) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
280 ms |
664 KB |
Output is correct |
3 |
Correct |
921 ms |
844 KB |
Output is correct |
4 |
Correct |
1076 ms |
960 KB |
Output is correct |
5 |
Correct |
996 ms |
888 KB |
Output is correct |
6 |
Correct |
806 ms |
824 KB |
Output is correct |
7 |
Correct |
1014 ms |
956 KB |
Output is correct |
8 |
Correct |
1052 ms |
648 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
200 KB |
Mismatch at position 3. Expected (, found ) |
2 |
Halted |
0 ms |
0 KB |
- |