#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#define pii pair<int, int>
#define piii pair<int, pii>
#define pll pair<long long, long long>
#define plll pair<long long, pll>
#define tiii tuple<int, int, int>
#define tiiii tuple<int, int, int, int>
#define ff first
#define ss second
#define ee ss.ff
#define rr ss.ss
#define DEBUG
using namespace std;
int main()
{
int n, q; cin >> n >> q;
string ans(n, ' ');
vector<int> ls[n + 1];
int val = 0;
for(int i = 0; i < n; ++i)
{
ls[val].push_back(i);
if(!val)
{
ans[i] = '(';
++val;
}
else
{
cout << "? " << ls[val - 1].back() + 1 << ' ' << i + 1 << endl; cout.flush();
int t; cin >> t;
if(t)
{
ans[i] = ')';
--val;
}
else
{
ans[i] = '(';
++val;
}
}
}
cout << ans << endl; cout.flush();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
200 KB |
Incorrect query () |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
200 KB |
Incorrect query (( |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
200 KB |
Incorrect query (()) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
200 KB |
Incorrect query (((( |
2 |
Halted |
0 ms |
0 KB |
- |