Submission #781294

#TimeUsernameProblemLanguageResultExecution timeMemory
781294makanhuliaZagrade (COI20_zagrade)C++17
71 / 100
645 ms680 KiB
#include<bits/stdc++.h> using namespace std; #define fi first #define se second #define pii pair<int,int> #define pll pair<long long, long long> int n,q,sisa; stack<int> st; char s[100069]; int main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); int i,j; cin>>n>>q; sisa = n/2; for(i=1;i<=n;i++) { if(st.empty()) { st.push(i); continue; } cout<<"? "<<st.top()<<" "<<i<<'\n'; cout.flush(); bool valid; cin>>valid; if(valid) { s[st.top()] = '('; s[i] = ')'; sisa--; st.pop(); } else { st.push(i); } } while(!st.empty()) { int x = st.top(); st.pop(); if(sisa) { s[x] = ')'; sisa--; } else { s[x] = '('; } } cout<<"! "; for(i=1;i<=n;i++) { cout<<s[i]; if(i == n) { cout<<'\n'; } } }

Compilation message (stderr)

zagrade.cpp: In function 'int main()':
zagrade.cpp:17:11: warning: unused variable 'j' [-Wunused-variable]
   17 |     int i,j;
      |           ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...