제출 #1153694

#제출 시각아이디문제언어결과실행 시간메모리
1153694gelastropodZagrade (COI20_zagrade)C++20
100 / 100
224 ms1924 KiB
#include <bits/stdc++.h> using namespace std; #define int long long signed main() { int N, Q, x; cin >> N >> Q; stack<int> stk; stk.push(-1); stk.push(0); vector<int> close(N, -1); //-1 unknown, 0 open, 1 close for (int i = 1; i < N; i++) { if (stk.top() == -1) { stk.push(i); continue; } cout << "? " << stk.top() + 1 << ' ' << i + 1 << endl; cin >> x; if (x) { close[stk.top()] = 0; close[i] = 1; stk.pop(); } else stk.push(i); } int unknown = 0; for (auto i : close) if (i == -1) unknown++; int count = 0; for (int i = 0; i < N && count < unknown / 2; i++) { if (close[i] == -1) { close[i] = 1; count++; } } cout << "! "; for (auto i : close) cout << (i > 0 ? ')' : '('); cout << 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...