Submission #585050

#TimeUsernameProblemLanguageResultExecution timeMemory
585050MetalPowerZagrade (COI20_zagrade)C++14
100 / 100
872 ms1020 KiB
#include <bits/stdc++.h> using namespace std; int query(int l, int r){ cout << "? " << l + 1 << " " << r + 1 << endl; int q; cin >> q; return q; } int N, Q; vector<int> st; vector<char> v; int main(){ cin >> N >> Q; v.resize(N, '-'); for(int i = 0; i < N; i++){ if(!st.empty()){ if(query(st.back(), i) == 1){ v[st.back()] = '(', v[i] = ')'; st.pop_back(); }else{ st.push_back(i); } }else{ st.push_back(i); } } for(int i = 0; i < st.size() / 2; i++) v[st[i]] = ')'; for(int i = st.size() / 2; i < st.size(); i++) v[st[i]] = '('; cout << "! "; for(int i = 0; i < N; i++) cout << v[i]; cout << endl; }

Compilation message (stderr)

zagrade.cpp: In function 'int main()':
zagrade.cpp:31:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |  for(int i = 0; i < st.size() / 2; i++) v[st[i]] = ')';
      |                 ~~^~~~~~~~~~~~~~~
zagrade.cpp:32:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |  for(int i = st.size() / 2; i < st.size(); i++) v[st[i]] = '(';
      |                             ~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...