#include<bits/stdc++.h>
using namespace std;
int main()
{
int n, q;
cin >> n >> q;
vector<int> v;
string ans;
for(int i = 1; i <= n; i ++)
{
if(v.empty()) {
ans += '(';
v.push_back(i);
}
else
{
cout << "? " << v.back() << ' ' << i << endl;
bool res;
cin >> res;
if(res)
ans += ')', v.pop_back();
else
ans += '(', v.push_back(i);
}
}
cout << "! " << ans << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
3 ms |
344 KB |
Output is correct |
3 |
Correct |
5 ms |
344 KB |
Output is correct |
4 |
Correct |
5 ms |
344 KB |
Output is correct |
5 |
Correct |
4 ms |
436 KB |
Output is correct |
6 |
Correct |
5 ms |
440 KB |
Output is correct |
7 |
Correct |
6 ms |
440 KB |
Output is correct |
8 |
Correct |
5 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Mismatch at position 1. Expected ), found ( |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
276 ms |
1016 KB |
Output is correct |
3 |
Correct |
575 ms |
1332 KB |
Output is correct |
4 |
Correct |
586 ms |
880 KB |
Output is correct |
5 |
Correct |
596 ms |
856 KB |
Output is correct |
6 |
Correct |
542 ms |
976 KB |
Output is correct |
7 |
Correct |
583 ms |
1176 KB |
Output is correct |
8 |
Correct |
560 ms |
876 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Mismatch at position 1. Expected ), found ( |
2 |
Halted |
0 ms |
0 KB |
- |