제출 #781277

#제출 시각아이디문제언어결과실행 시간메모리
781277andecaandeciZagrade (COI20_zagrade)C++17
71 / 100
784 ms1196 KiB
#include <bits/stdc++.h> #define int long long #define pb push_back #define pii pair<int, int> #define fr first #define sc second #define query(l, r) cout << "? " << l << " " << r << endl; cin >> res; using namespace std; const int N = 1e5 + 5; string ans; bool res; signed main() { ios_base::sync_with_stdio(false); cout.tie(NULL); cin.tie(NULL); int n, q; cin >> n >> q; ans.assign(n, ' '); for (int i = 0; i < n / 2; i++) ans[i] = ')'; for (int i = n / 2; i < n; i++) ans[i] = '('; stack<int> s; s.push(1); for (int i = 2; i <= n; i++) { if (s.empty()) { s.push(i); continue; } int cur = s.top(); query(cur, i); if (res) { ans[cur - 1] = '('; ans[i - 1] = ')'; s.pop(); } else s.push(i); } cout << "! " << ans << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...