Submission #1018514

#TimeUsernameProblemLanguageResultExecution timeMemory
1018514kukukZagrade (COI20_zagrade)C++14
100 / 100
586 ms1812 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int ukr = 1e5+10; ll n, m, id, a, b; char ar[ukr]; vector<int> v; int ask(int a, int b){ cout << "? " << a << " " << b << endl; int kkl; cin >> kkl; return kkl; } void solve(){ cin >> n >> m; for(int i = 1; i <= n; i++){ ar[i] = '.'; } ll pke = 0; for(int i = 1; i <= n; i++){ if(v.empty()){ v.push_back(i); }else{ if(ask(v.back(), i)){ ar[v.back()] = '('; ar[i] = ')'; v.pop_back(); pke += 2; }else{ v.push_back(i); } } } pke = n-pke; pke/=2; cout << "! "; for(int i = 1; i <= n; i++){ if(ar[i] == '.'){ if(!pke){ ar[i] = '('; }else{ pke--; ar[i] = ')'; } } cout << ar[i]; } cout << endl; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t = 1; //cin >> t; while(t--){ 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...