Submission #103818

#TimeUsernameProblemLanguageResultExecution timeMemory
103818beso123Combo (IOI18_combo)C++14
5 / 100
2 ms200 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; /*string pas; int qu; int press(string s){ qu++; int r=0; 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 a="ABXY"; string guess_sequence(int N){ string s=""; int num,i=0; string b; s=a[0]; s+=a[1]; num=press(s); if(num>=1){ s=a[0]; if(press(s)==1){ b+=s; a.erase(0,1); } else{ b+=a[1]; a.erase(1,1); } } else{ s=a[2]; if(press(s)){ b+=s; a.erase(2,1); } else{ b+=a[3]; a.erase(3,1); } } while((int)b.size()<N-1){ string c=b+a[0]+b+a[1]+a[0]+b+a[1]+a[2]+b+a[1]+a[1]; int ps=press(c); if(ps==b.size()) b+=a[2]; else{ if(ps==b.size()+1) b+=a[0]; else if(ps==b.size()+2) b+=a[1]; } } s=b+a[0]; if(press(s)==b.size()+1) return s; s=b+a[1]; if(press(s)==b.size()+1) return s; s=b+a[2]; return s; } /*int main(){ while(1){ cin>>pas; string s=guess_sequence(pas.size()); cout<<s<<' '<<qu<<endl; } return 0; }*/

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:51:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |   if(ps==b.size())
      |      ~~^~~~~~~~~~
combo.cpp:54:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |   if(ps==b.size()+1)
      |      ~~^~~~~~~~~~~~
combo.cpp:57:8: 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(ps==b.size()+2)
      |      ~~^~~~~~~~~~~~
combo.cpp:62:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 | if(press(s)==b.size()+1)
      |    ~~~~~~~~^~~~~~~~~~~~
combo.cpp:65:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 | if(press(s)==b.size()+1)
      |    ~~~~~~~~^~~~~~~~~~~~
combo.cpp:21:9: warning: unused variable 'i' [-Wunused-variable]
   21 | int num,i=0;
      |         ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...