Submission #713096

#TimeUsernameProblemLanguageResultExecution timeMemory
713096dungnguyenn_05Combo (IOI18_combo)C++17
97 / 100
34 ms568 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=3; for(int i=0;i<3;i++) { string s; s+=c[i]; int val=press(s); if(val) { start=i; break; } } 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:37:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   37 |     while(cur.size()<N-1)
      |           ~~~~~~~~~~^~~~
combo.cpp:75:18: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   75 |     if(cur.size()<N)
      |        ~~~~~~~~~~^~
combo.cpp:87:18: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   87 |     if(cur.size()<N)
      |        ~~~~~~~~~~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...