Submission #960989

#TimeUsernameProblemLanguageResultExecution timeMemory
960989aminjon__Combo (IOI18_combo)C++17
100 / 100
15 ms2036 KiB
#include<bits/stdc++.h> using namespace std; deque<char> button = {'A' , 'B', 'X' , 'Y'}; int press(string s); string c; int N; int G = 0; // int press(string a){s // G++; // int rrv = 0; // for(int i = 0;i < a.size();i++){ // int cnt = 0; // for(int j = i;j < a.size() && (j-i) < c.size();j++){ // if(a[j] == c[j-i]){ // cnt++; // rrv=max(rrv , cnt); // } // else{ // break; // } // } // } // return rrv; // } string guess_sequence(int N){ string ans; if(press("AB") > 0){ if(press("A") > 0){ ans = "A"; button.erase(button.begin()); } else{ ans = "B"; button.erase(button.begin()+1); } } else{ if(press("X") > 0){ ans = "X"; button.erase(button.begin()+2); } else{ ans = "Y"; button.erase(button.begin()+3); } } if(N == 1){ return ans; } for(int i = 2;i <= N-1;i++){ int r = press(ans+button[1] + ans+button[2]+button[0]+ans+button[2]+button[1]+ans+button[2]+button[2] ); ans += button[r - ans.size()]; } if(press(ans+button[0]+ans+button[1]) > ans.size()){ if(press(ans+button[0]) > ans.size()){ ans += button[0]; } else{ ans += button[1]; } } else{ ans += button[2]; } return ans; } // int main(){ // cin >> N >> c; // cout<<guess_sequence(N); // // return 0; // }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:56:40: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |  if(press(ans+button[0]+ans+button[1]) > ans.size()){
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
combo.cpp:57:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |   if(press(ans+button[0]) > ans.size()){
      |      ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...