#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long;
const ll mod = 998244353;
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define faster ios::sync_with_stdio(false);cin.tie(nullptr)
int main() {
ll N,Q;
cin >> N >> Q;
vector<char> ans(N,'-');
ll last=N;
rep(i,N){
if(ans[i]!='-') continue;
for(ll j=i+1;j<N;j+=2){
if(ans[j]!='-') continue;
cout << "?" << " " << i+1 << " " << j+1 << endl;
ll q;
cin >> q;
if(q==1){
ans[i]='(';
ans[j]=')';
last=j;
break;
}
}
if(ans[i]=='-'){
ans[i]=')';
ans[last-1]='(';
last=last-1;
}
}
cout << "!" << " ";
rep(i,N) cout << ans[i];
cout << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
2 ms |
344 KB |
Output is correct |
3 |
Correct |
14 ms |
344 KB |
Output is correct |
4 |
Correct |
13 ms |
540 KB |
Output is correct |
5 |
Correct |
32 ms |
344 KB |
Output is correct |
6 |
Correct |
47 ms |
344 KB |
Output is correct |
7 |
Correct |
578 ms |
344 KB |
Output is correct |
8 |
Correct |
20 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
709 ms |
344 KB |
Output is correct |
3 |
Runtime error |
284 ms |
408 KB |
Execution killed with signal 6 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
271 ms |
504 KB |
Output is correct |
3 |
Runtime error |
493 ms |
512 KB |
Execution killed with signal 13 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Runtime error |
476 ms |
512 KB |
Execution killed with signal 13 |
3 |
Halted |
0 ms |
0 KB |
- |