Submission #706426

#TimeUsernameProblemLanguageResultExecution timeMemory
706426vjudge1Zagrade (COI20_zagrade)C++17
100 / 100
1074 ms1080 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long // #define endl '\n' #define all(x) x.begin(),x.end() const int MOD = 1e9 + 7, SZ = 1e5 + 100, MX = 1e9; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, q; cin >> n >> q; int p[n+2], s[n+1]={}, x = n/2; for(int i=1;i<=n;i++) p[i] = i-1; for(int i=1;i<=n;i++){ if(p[i] == 0) continue; int ans; cout.flush() << "? " << p[i] << ' ' << i << endl; cin >> ans; if(ans == 1){ s[i] = 2; s[p[i]] = 1; x--; p[i+1] = p[p[i]]; } } int a = x, b = x; for(int i=1;i<=n;i++){ if(s[i]) continue; if(a){ a--; s[i] = 2; } else s[i] = 1; } cout.flush() << "! "; for(int i=1;i<=n;i++) cout.flush() << (s[i] == 2 ? ')' : '('); return 0; }

Compilation message (stderr)

zagrade.cpp: In function 'int main()':
zagrade.cpp:27:16: warning: unused variable 'b' [-Wunused-variable]
   27 |     int a = x, b = x;
      |                ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...