제출 #976848

#제출 시각아이디문제언어결과실행 시간메모리
976848efedmrlrZagrade (COI20_zagrade)C++17
0 / 100
1 ms552 KiB
#include <bits/stdc++.h> #define lli long long int #define ld long double #define pb push_back #define MP make_pair #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define REP(i, n) for(int i = 0; (i) < (n); (i)++) using namespace std; void fastio() { ios_base::sync_with_stdio(false); cin.tie(NULL); } const int N = 1e5 + 5; const int INF = 1e9 + 500; vector<char> res(N); int n, q; bool query(int l, int r) { cout << "? " << l << " " << r << endl; bool x; cin >> x; return x; } void answer() { cout << "! "; for(int i = 1; i <= n; i++) { cout << res[i]; } cout << endl; } void solve() { cin >> n >> q; int l = 1; res[1] = '('; vector<int> op; op.pb(1); for(int r = 2; r <= n; ) { bool x = query(l, r); if(x) { res[r] = ')'; op.pop_back(); } else { res[r] = '('; op.pb(r); } r++; if(op.empty()) { l = r; r++; } else { l = op.back(); } } answer(); } signed main() { fastio(); solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...