Submission #773489

#TimeUsernameProblemLanguageResultExecution timeMemory
773489vjudge1Zagrade (COI20_zagrade)C++17
71 / 100
737 ms3136 KiB
#include <bits/stdc++.h> using namespace std; #define sp " " //#define endl "\n" #define fileio() freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout) #define fastio() cin.tie(0), ios_base::sync_with_stdio(0) #define pb push_back #define pii pair<int, int> #define st first #define nd second #define N 200005 int ask(int a, int b){ cout<<"? "<<a<<sp<<b<<endl; int res; cin>>res; return res; } int32_t main(){ //fileio(); //fastio(); int n, q; cin>>n>>q; vector<int> arr; map<int ,int> pos; int curr = 0, it = 1; while(it < n){ int res = ask(it, it + 1); if (res == 1) arr.pb(1), arr.pb(-1), pos[1] = it, pos[0] = it + 1; else arr.pb(1), arr.pb(1), curr = 2, pos[1] = it, pos[2] = it + 1; for (it += 2; it <= n; it++){ if (curr == 0) break; int to = pos[curr - 1] + 1; int res = ask(to, it); if (res == 1){ curr -= 1; arr.pb(-1); } else{ curr += 1; arr.pb(1); } pos[curr] = it; } } cout<<"! "; for (auto i : arr){ cout<<((i == 1) ? '(' : ')'); } cout<<endl; //cerr<<"time taken : "<<(float)clock() / CLOCKS_PER_SEC<<" seconds\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...