#include <bits/stdc++.h>
#define inf INT_MAX
#define longlonginf LONG_LONG_MAX
#define mod 998244353
#define MAXN 200005
#define pii pair<ll,ll>
#define ll long long
#define deb(x) cerr<<"[ "<<#x<<" = "<<x<<" ]";
#define yes() cout<<"YES\n";
#define no() cout<<"NO\n";
using namespace std;
ll n,k,m,q,cur,z;
ll ans = 0;
string subtask;
void solve(){
cin>>n>>q;
ll rem = n/2;
stack<int> s;
string res = string(n,'.');
for(int i = 1 ; i <= n ; i++){
if( s.empty() ) {
s.push(i);
continue;
}
cout<<"? "<<s.top()<<" "<<i<<endl;
cin>>k;
if(k){
res[s.top()-1] = '(';
res[i-1] = ')';
s.pop();
rem--;
}
else{
s.push(i);
}
}
for(int i = 0 ; i < rem/2 ; i++) {
res[s.top()] = ')';
s.pop();
}
for(int i = 0 ; i < rem/2 ; i++) {
res[s.top()] = '(';
s.pop();
}
cout<<"! "<<res<<endl;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int T = 1;
//cin>>T;
for(int i = 0 ; i < T ; i++){
//cout<<"Case #"<<i+1<<": ";
solve();
}
return 0;
}
/*
out of bound for loop
(constraint change in loop)
forget to change bool to int
misread -> missed subtask
you thought u declared it huh?
not i but x
logical operator
wrong example/proof
thoroughly
wrong variables
thinking it wrong
bruh just try some test case
capitals ;-;
wrong data structure lol
count memory usement
corner case
oversized array
orders
statements
size initializer
while con
map -> array
wrong digits??
swapped variables??
check if theres any variabled
that got declared twice
find some pattern
name collision
constraints??!
mod !!
resets
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
2 ms |
344 KB |
Output is correct |
3 |
Correct |
3 ms |
344 KB |
Output is correct |
4 |
Correct |
3 ms |
344 KB |
Output is correct |
5 |
Correct |
4 ms |
500 KB |
Output is correct |
6 |
Correct |
7 ms |
340 KB |
Output is correct |
7 |
Correct |
3 ms |
344 KB |
Output is correct |
8 |
Correct |
3 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 |
226 ms |
528 KB |
Output is correct |
3 |
Correct |
502 ms |
528 KB |
Output is correct |
4 |
Correct |
437 ms |
528 KB |
Output is correct |
5 |
Correct |
476 ms |
780 KB |
Output is correct |
6 |
Correct |
462 ms |
528 KB |
Output is correct |
7 |
Correct |
464 ms |
1708 KB |
Output is correct |
8 |
Correct |
492 ms |
528 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
344 KB |
Mismatch at position 1. Expected ), found . |
2 |
Halted |
0 ms |
0 KB |
- |