Submission #713100

#TimeUsernameProblemLanguageResultExecution timeMemory
713100dungnguyenn_05Combo (IOI18_combo)C++17
100 / 100
55 ms580 KiB
#include "combo.h" #include<bits/stdc++.h> #define fs first #define sc second #define pb push_back #define all(x) x.begin()x.end() using namespace std; typedef vector<int> vi; typedef pair<int,int> pi; char c[5]={'A','B','X','Y'}; vi ava; std::string guess_sequence(int N) { int start; string ask; ////////////////////// ask+=c[0]; ask+=c[1]; int val=press(ask); if(val) { ask=""; ask+=c[0]; val=press(ask); if(val) start=0; else start=1; } else { ask=""; ask+=c[2]; val=press(ask); if(val) start=2; else start=3; } string cur; cur+=c[start]; for(int i=0;i<4;i++) if(i!=start) ava.pb(i); while(cur.size()<N-1) { // cout<<"cur "<<cur<<endl; string ask; /////////////////// ask+=cur; ask+=c[ava[0]]; /////////////////// ask+=cur; ask+=c[ava[1]]; ask+=c[ava[0]]; /////////////////// ask+=cur; ask+=c[ava[1]]; ask+=c[ava[1]]; /////////////////// ask+=cur; ask+=c[ava[1]]; ask+=c[ava[2]]; /////////////////// int val=press(ask)-cur.size(); // cout<<ask<<' '<<val<<endl; if(!val) cur+=c[ava[2]]; if(val==1) cur+=c[ava[0]]; if(val==2) cur+=c[ava[1]]; } if(cur.size()<N) { string ask; ask=cur+c[ava[0]]; if(press(ask)-cur.size()>0) cur+=c[ava[0]]; ask=cur+c[ava[1]]; if(press(ask)-cur.size()>0) cur+=c[ava[1]]; } if(cur.size()<N) cur+=c[ava[2]]; // cout<<cur<<endl; return cur; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:54:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   54 |     while(cur.size()<N-1)
      |           ~~~~~~~~~~^~~~
combo.cpp:92:18: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   92 |     if(cur.size()<N)
      |        ~~~~~~~~~~^~
combo.cpp:104:18: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  104 |     if(cur.size()<N)
      |        ~~~~~~~~~~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...