Submission #1003770

#TimeUsernameProblemLanguageResultExecution timeMemory
1003770vjudge1Zagrade (COI20_zagrade)C++17
100 / 100
588 ms1368 KiB
#include <bits/stdc++.h> using namespace std; int main(){ int n,q; cin >> n >> q; string res = string(n, '?'); stack<int> ultimo; int i=1; while(i<n){ cout << "? "<< i << ' '<< i+1 << endl; int ans; cin >> ans; if(ans == 1){ res[i-1] = '('; res[i]=')'; i = i+2; while(ultimo.size()!=0 and i<= n){ cout << "? "<< ultimo.top()<< ' '<< i << endl; int outro; cin >> outro; if(outro == 1){ res[ultimo.top()-1]='('; res[i-1] = ')'; i++; ultimo.pop(); } else break; } } else{ ultimo.push(i); i++; } } int falta=0; for(auto j: res) if(j == '?') falta++; int qnt = 0; for(int j=0; j<res.size(); j++){ if(res[j] != '?')continue; if(qnt <(falta/2)) res[j] = ')'; else res[j] = '('; qnt++; } cout << "! "<< res << endl; }

Compilation message (stderr)

zagrade.cpp: In function 'int main()':
zagrade.cpp:41:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |     for(int j=0; j<res.size(); 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...