Submission #1003936

#TimeUsernameProblemLanguageResultExecution timeMemory
1003936vjudge1Zagrade (COI20_zagrade)C++17
71 / 100
574 ms1672 KiB
#include <bits/stdc++.h> using namespace std; int marc[100005]; stack<int> st; int main(){ int n,q; cin>>n>>q; cout<<"? "<<1<<" "<<n<<" "<<endl; int y; cin>>y; if(y == 1){ marc[n] = 0; for(int i = 1; i < n; i++){ if(st.size() == 0){ marc[i] = 1; st.push(i); continue; } cout<<"? "<<st.top()<<" "<<i<<endl; int x; cin>>x; if(x == 0){ marc[i] = 1; st.push(i); }else{ marc[i] = 0; st.pop(); } } cout<<"! "; for(int i = 1; i <= n; i++){ if(marc[i] == 0)cout<<")"; else cout<<"("; }cout<<endl; return 0; } else{ for(int i = 1; i <= n; i++)marc[i] = -1; marc[n] = 1; int qtd = 0; for(int i = 1; i < n; i++){ if(st.size() == 0){ st.push(i); continue; } cout<<"? "<<st.top()<<" "<<i<<endl; int x; cin>>x; if(x == 1){ qtd++; marc[st.top()] = 1; marc[i] = 0; st.pop(); }else{ st.push(i); } } for(int i = 1; i <= n; i++) if(marc[i] == -1){ if(qtd < n/2){marc[i] = 0; qtd++;} else marc[i] = 1; } cout<<"! "; for(int i = 1; i <= n; i++){ if(marc[i] == 0)cout<<")"; else cout<<"("; }cout<<endl; return 0; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...