This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef string str;
typedef pair <int, int> ii;
#define file "TEST"
#define st first
#define nd second
#define pb push_back
#define vll vector<ll>
#define vi vector<int>
#define all(v) (v).begin(), (v).end()
#define FOR(i,x,y) for(ll i = x; i <= y; ++i)
#define FOS(i,x,y) for(ll i = x; i >= y; --i)
#define EACH(i,x) for (auto &(i) : (x))
#define el cout << endl
const ll MOD = 1e9 + 7;
#define dbg(...) cerr << "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define dbge(...) cerr << "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]" << endl;
/*
mt19937_64 rd(chrono::steady_clock::now().time_since_epoch().count());
ll rand(ll l, ll r) { return uniform_int_distribution<ll>(l, r)(rd); }
*/
const int N = 1e5 + 1;
int n, k;
stack<int> Q;
int ask (int l, int r) {
cout << "? " << l << " " << r << endl;
int m; cin >> m;
return m;
}
char res[N];
int main()
{
ios_base::sync_with_stdio(0);
// freopen("TEST.inp", "r", stdin);
// freopen("TEST.out", "w", stdout);
cin.tie(0);
cout.tie(0);
cin >> n >> k;
Q.push(1);
res[1] = '(';
for (int i = 2; i <= n; ++i) {
if (!Q.empty() && ask(Q.top(), i)) {
res[i] = ')';
Q.pop();
}
else {
res[i] = '(';
Q.push(i);
}
}
cout << "! ";
for (int i = 1; i <= n; ++i) cout << res[i];
cout << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |