#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const int N = 100000;
int val[N+5];
int main(){
ios_base::sync_with_stdio(false), cin.tie(0);
cout.precision(10);
cout << fixed;
int n, qrs;
cin >> n >> qrs;
stack <int> st;
for(int i=1; i<=n; i++){
if(st.size()){
cout << "? " << st.top() << " " << i << endl;
int x;
cin >> x;
if(x){
val[st.top()] = 1;
st.pop();
}
else st.push(i);
}
else st.push(i);
}
int x = st.size()/2;
while(x){
val[st.top()] = 1;
st.pop();
x--;
}
cout << "! ";
for(int i=1; i<=n; i++){
if(val[i]) cout << "(";
else cout << ")";
}
cout << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
4 ms |
208 KB |
Output is correct |
3 |
Correct |
7 ms |
208 KB |
Output is correct |
4 |
Correct |
9 ms |
208 KB |
Output is correct |
5 |
Correct |
9 ms |
208 KB |
Output is correct |
6 |
Correct |
6 ms |
208 KB |
Output is correct |
7 |
Correct |
8 ms |
208 KB |
Output is correct |
8 |
Correct |
7 ms |
320 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
11 ms |
208 KB |
Output is correct |
3 |
Correct |
9 ms |
324 KB |
Output is correct |
4 |
Correct |
6 ms |
208 KB |
Output is correct |
5 |
Correct |
9 ms |
208 KB |
Output is correct |
6 |
Correct |
10 ms |
208 KB |
Output is correct |
7 |
Correct |
6 ms |
208 KB |
Output is correct |
8 |
Correct |
8 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
323 ms |
872 KB |
Output is correct |
3 |
Correct |
756 ms |
912 KB |
Output is correct |
4 |
Correct |
800 ms |
876 KB |
Output is correct |
5 |
Correct |
673 ms |
832 KB |
Output is correct |
6 |
Correct |
793 ms |
1024 KB |
Output is correct |
7 |
Correct |
667 ms |
884 KB |
Output is correct |
8 |
Correct |
816 ms |
796 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
703 ms |
900 KB |
Output is correct |
3 |
Correct |
763 ms |
1000 KB |
Output is correct |
4 |
Correct |
814 ms |
1220 KB |
Output is correct |
5 |
Correct |
775 ms |
896 KB |
Output is correct |
6 |
Correct |
826 ms |
976 KB |
Output is correct |
7 |
Correct |
790 ms |
824 KB |
Output is correct |
8 |
Correct |
501 ms |
776 KB |
Output is correct |