Submission #1120169

#TimeUsernameProblemLanguageResultExecution timeMemory
112016912345678Zagrade (COI20_zagrade)C++17
0 / 100
63 ms436 KiB
#include <bits/stdc++.h> using namespace std; const int nx=1e3+5; int n, q, cnt, res[nx], x; int query(int l, int r) { cout<<"? "<<l<<' '<<r<<'\n'; fflush(stdout); cin>>x; return x; } void solve(int l, int r) { if (l<1||r>n||res[l]||res[r]) return; if (query(l, r)) res[l]=1, res[r]=2, cnt+=2, solve(l-1, r+1); } int main() { //cin.tie(NULL)->sync_with_stdio(false); cin>>n>>q; for (int i=1; i<=n; i++) { if (res[i]) continue; solve(i, i+1); } cnt=(n-cnt)/2; for (int i=1; i<=n; i++) { if (!res[i]&&cnt>0) cnt--, res[i]=2; else res[i]=1; } cout<<"! "; for (int i=1; i<=n; i++) cout<<((res[i]==1)?'(':')'); fflush(stdout); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...