This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
int main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
auto qry = [&](int i, int j) {
cout << "? " << i + 1 << " " << j + 1 << endl;
int r; cin >> r;
return r;
};
int n, q; cin >> n >> q;
string s(n, '(');
vector<int> st{0};
int cnt = n / 2;
for (int i = 1; i < n; ++i) {
if (st.size() && qry(st.back(), i)) {
s[i] = ')';
--cnt;
st.pop_back();
} else {
st.push_back(i);
}
}
for (int i = 0; i < cnt; ++i) {
s[st[i]] = ')';
}
cout << "! " << s << 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... |