#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
cin.tie(0); ios_base::sync_with_stdio(0);
int n, q;
cin >> n >> q;
vector<int> ans(n, -1);
for(int i = 0; i < n - 1; i++) {
cout << "? " << i + 1 << " " << i + 2 << endl;
int x; cin >> x;
if(x) {
ans[i] = 1;
ans[i + 1] = 0;
i++;
}
}
cout << "! ";
for(int i = 0; i < n; i++) {
if(ans[i] == -1) {
int cnt = 0;
int j = i;
for(; ans[j] == -1; j++) {
ans[j] = 1;
cnt++;
}
while(ans[j] != -1) j++;
for(; cnt > 0; j++, cnt--) {
ans[j] = 0;
}
}
cout << (ans[i] ? '(' : ')');
}
cout << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
6 ms |
208 KB |
Output is correct |
3 |
Incorrect |
3 ms |
208 KB |
Mismatch at position 12. Expected (, found ) |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
444 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
462 ms |
700 KB |
Output is correct |
3 |
Runtime error |
686 ms |
1164 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
336 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |