제출 #1149413

#제출 시각아이디문제언어결과실행 시간메모리
1149413PwoZagrade (COI20_zagrade)C++20
14 / 100
836 ms772 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int n, q; char ch[100005]; int ask(int i, int j) { cout << "? " << i << ' ' << j << endl; int res; cin >> res; return res; } int32_t main() { cin >> n >> q; for (int i = 1; i <= n; i++) ch[i] = '.'; for (int i = 1; i < n; i++) { if (ch[i] != '.') continue; for (int j = i + 1; j <= n; j += 2) { if (ch[j] != '.') continue; if (q < 0) return 0; q--; int res = ask(i, j); if (res) { ch[i] = '('; ch[j] = ')'; } } } int cnt = 0; for (int i = 1; i <= n; i++) if (ch[i] == ')') cnt++; string s = ""; for (int i = 1; i <= n; i++) { if (ch[i] != '.') s += ch[i]; else if (cnt * 2 < n) { s += ')'; cnt++; } else s += '('; } cout << "! " << s << 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...