#include <bits/stdc++.h>
using namespace std;
int main(){
int n,k; cin >> n>> k;
stack<int> aberto;
aberto.push(1);
string res = "(";
for(int i=2; i<=n; i++){
if(aberto.size() == 0){
aberto.push(i);
res += '(';
continue;
}
int aux = aberto.top();
cout << "? "<< aux << ' '<< i<< endl;
int ans; cin >> ans;
if(ans == 1){
aberto.pop();
res+=')';
}
else{
aberto.push(i);
res += '(';
}
}
cout << "! " << res << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
2 ms |
344 KB |
Output is correct |
3 |
Correct |
4 ms |
432 KB |
Output is correct |
4 |
Correct |
5 ms |
344 KB |
Output is correct |
5 |
Correct |
5 ms |
344 KB |
Output is correct |
6 |
Correct |
4 ms |
344 KB |
Output is correct |
7 |
Correct |
4 ms |
340 KB |
Output is correct |
8 |
Correct |
4 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 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 |
300 ms |
1116 KB |
Output is correct |
3 |
Correct |
596 ms |
1116 KB |
Output is correct |
4 |
Correct |
565 ms |
876 KB |
Output is correct |
5 |
Correct |
576 ms |
1284 KB |
Output is correct |
6 |
Correct |
572 ms |
980 KB |
Output is correct |
7 |
Correct |
560 ms |
1208 KB |
Output is correct |
8 |
Correct |
613 ms |
1260 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Mismatch at position 1. Expected ), found ( |
2 |
Halted |
0 ms |
0 KB |
- |