Submission #93317

#TimeUsernameProblemLanguageResultExecution timeMemory
93317beso123Combo (IOI18_combo)C++14
5 / 100
2 ms256 KiB
#include <bits/stdc++.h> #include "combo.h" int cnt; using namespace std; string a="ABXY"; /*string pas="YXXXBBBAAA"; int press(string s){ int r=0; cnt++; string b=""; for(int k=0;k<pas.size();k++){ b=b+pas[k]; if(s.find(b)==-1) return r; r++; } return r; }*/ string guess_sequence(int N){ string s=""; string b=""; if(N==3){ int r=1; while(s.size()<N){ for(int k=0;k<a.size();k++){ string b=s+a[k]; if(k==a.size()-1){ s=b; r++; if(r==2){ if(b=="A") a.erase(0,1); if(b=="B") a.erase(1,1); if(b=="X") a.erase(2,1); if(b=="Y") a.erase(3,1); } break; } else if(press(b)==r){ s=b; r++; if(r==2){ if(b=="A") a.erase(0,1); if(b=="B") a.erase(1,1); if(b=="X") a.erase(2,1); if(b=="Y") a.erase(3,1); } break; } } } return s; } if(press(s+"B")==1){ a.erase(1,1); s=s+"B"; } else{ if(press(s+"A")==1){ a.erase(0,1); s=s+"A"; } else{ if(press(s+"X")==1){ a.erase(2,1); s=s+"X"; } else{ a.erase(3,1); s=s+"Y"; } } } while(s.size()<N-1){ //cout<<a<<endl; string c=s+a[0]+s+a[1]+a[0]+s+a[1]+a[2]+s+a[1]+a[1]; int ps=press(c); if(ps==s.size()) s+=a[2]; else{ if(ps==s.size()+1) s+=a[0]; else if(ps==s.size()+2) s+=a[1]; } } for(int k=0;k<a.size();k++){ if(k==2){ b=s+a[k]; break; } else{ string i=s+a[k]; if(press(i)==N){ b=s+a[k]; break; } } } s=b; return s; } /*int main(){ string s=guess_sequence(pas.size()); cout<<s<<' '<<cnt; return 0; }*/

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:24:15: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   24 | while(s.size()<N){
      |       ~~~~~~~~^~
combo.cpp:25:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 | for(int k=0;k<a.size();k++){
      |             ~^~~~~~~~~
combo.cpp:27:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |    if(k==a.size()-1){
      |       ~^~~~~~~~~~~~
combo.cpp:90:15: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   90 | while(s.size()<N-1){
      |       ~~~~~~~~^~~~
combo.cpp:94:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   94 |   if(ps==s.size())
      |      ~~^~~~~~~~~~
combo.cpp:97:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   97 |   if(ps==s.size()+1)
      |      ~~^~~~~~~~~~~~
combo.cpp:100:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  100 |   if(ps==s.size()+2)
      |      ~~^~~~~~~~~~~~
combo.cpp:104:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  104 | for(int k=0;k<a.size();k++){
      |             ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...