Submission #103815

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

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:49:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |   if(ps==b.size())
      |      ~~^~~~~~~~~~
combo.cpp:52:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |   if(ps==b.size()+1)
      |      ~~^~~~~~~~~~~~
combo.cpp:55:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |   if(ps==b.size()+2)
      |      ~~^~~~~~~~~~~~
combo.cpp:64:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |  if(num==b.size()+1){
      |     ~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...