Submission #779913

#TimeUsernameProblemLanguageResultExecution timeMemory
779913makanhuliaZagrade (COI20_zagrade)C++17
100 / 100
816 ms1100 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define ull unsigned long long #define ld long double #define fi first #define se second vector<int> v; int ans[100005]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, q, cnt = 0; cin >> n >> q; v.push_back(1); for (int i = 2; i <= n; i++) { if (v.empty()) { v.push_back(i); continue; } int id = v.back(); cout << "? " << id << " " << i << endl; bool in; cin >> in; if (in) cnt++, ans[id] = 1, ans[i] = 2, v.pop_back(); else v.push_back(i); } cnt = n / 2 - cnt; cout << "! "; for (int i = 1; i <= n; i++) { if (ans[i] == 1) cout << '('; else if (ans[i] == 2) cout << ')'; else if (cnt > 0) { cout << ')'; cnt--; } else cout << '('; } 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...