Submission #93351

#TimeUsernameProblemLanguageResultExecution timeMemory
93351beso123Combo (IOI18_combo)C++14
0 / 100
2 ms200 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; string a="ABXY"; //string pas="XA"; /*int press(string s){ 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 guess_sequence(int N){ string s=""; string b=""; for(int k=0;k<a.size();k++){ if(k==3){ b=s+a[k]; a.erase(3,1); break; } else{ if(press(s+a[k])==1){ b=s+a[k]; a.erase(k,1); break; } } } s=b; while(s.size()<N-1){ 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==a.size()-1){ b=s+a[k]; break; } else{ if(press(s+a[k])==1){ b=s+a[k]; break; } } } return s; } /*int main(){ string s=guess_sequence(pas.size()); cout<<s; return 0; }*/

Compilation message (stderr)

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