Submission #798748

#TimeUsernameProblemLanguageResultExecution timeMemory
798748exodus_Zagrade (COI20_zagrade)C++14
100 / 100
859 ms692 KiB
#include<bits/stdc++.h> using namespace std; char result[100001]; int main() { int N, Q; stack<int>tunggu; cin >> N >> Q; int half=N/2; bool apa; for (int i=1; i<=N; i++) { if(tunggu.empty()==true) { tunggu.push(i); } else { cout << "? " << tunggu.top() << " " << i << endl; cout << flush; cin >> apa; if(apa==true) { result[tunggu.top()]='('; result[i]=')'; half--; tunggu.pop(); } else { tunggu.push(i); } } } while(!tunggu.empty()) { if(half!=0) { result[tunggu.top()]='('; half--; tunggu.pop(); } else { result[tunggu.top()]=')'; tunggu.pop(); } } cout << "! "; for (int i=1; i<=N; i++) { cout << result[i]; } 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...