Submission #407418

#TimeUsernameProblemLanguageResultExecution timeMemory
407418ngraceCombo (IOI18_combo)C++14
100 / 100
39 ms580 KiB
#include "combo.h" #include <string> #include <vector> #include <iostream> using namespace std; std::string guess_sequence(int N) { string s = ""; //find first char start='1'; if(N==1){ if(press("A")){ start='A'; } else if(press("B")){ start='B'; } else if(press("X")){ start='X'; } else{ start='Y'; } } else{ if(press("AB")){ if(press("A")){ start='A'; } else{ start='B'; } } else{ if(press("X")){ start='X'; } else{ start='Y'; } } } s.push_back(start); vector<char> but; if(start=='A'){ but={'B','X','Y'}; } else if(start=='B'){ but={'A','X','Y'}; } else if(start=='X'){ but={'A','B','Y'}; } else{ but={'A','B','X'}; } for(int i=1;i<N-1;i++){ string q=""; q.append(s); q.push_back(but[0]); q.append(s); q.push_back(but[1]); q.push_back(but[0]); q.append(s); q.push_back(but[1]); q.push_back(but[1]); q.append(s); q.push_back(but[1]); q.push_back(but[2]); //cout<<q<<endl; int qu=press(q); if(qu==i+0){ s.push_back(but[2]); } else if(qu==i+1){ s.push_back(but[0]); } else{ s.push_back(but[1]); } //cout<<qu<<endl; //cout<<s.back()<<endl; } //now get last element if(s.size()<N){ for(int i=0;i<2;i++){ s.push_back(but[i]); if(press(s)==N){ break; } s.pop_back(); } if(s.size()<N){ s.push_back(but[2]); } } //cout<<s<<endl; return s; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:90:14: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   90 |   if(s.size()<N){
      |      ~~~~~~~~^~
combo.cpp:98:16: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   98 |     if(s.size()<N){
      |        ~~~~~~~~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...