Submission #820632

#TimeUsernameProblemLanguageResultExecution timeMemory
820632dashkaCombo (IOI18_combo)C++14
100 / 100
25 ms664 KiB
#include <bits/stdc++.h> std::string s; std::vector<char> c; int press(std::string); std::string make(std::string cur){ std::string ret; for(int i{}; i < 3; ++i){ ret+=cur; ret.push_back(c[0]); ret.push_back(c[i]); } ret+=cur; ret.push_back(c[1]); return ret; } std::string guess_sequence(int n){ int val=press("AB"); if(val) s=(press("A")==1?"A":"B"); else s=(press("X")==1?"X":"Y"); std::string all{"ABXY"}; for(char ch: all) if(s[0]!=ch) c.push_back(ch); while(s.size()<n-1){ int k=s.size(); int cur=press(make(s)); if(cur==k) s.push_back(c[2]); else if(cur==k+1) s.push_back(c[1]); else s.push_back(c[0]); } if(s.size()==n-1){ std::string curs=s; curs.push_back(c[0]); curs+=s; curs.push_back(c[1]); if(press(curs)==n-1) s.push_back(c[2]); else{ curs=s; curs.push_back(c[0]); if(press(curs)==n) s.push_back(c[0]); else s.push_back(c[1]); } } return s; }

Compilation message (stderr)

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