Submission #380825

#TimeUsernameProblemLanguageResultExecution timeMemory
380825knightron0Combo (IOI18_combo)C++14
5 / 100
2 ms264 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; // string S; // int press(string p) { // int coins = 0; // for (int i = 0, j = 0; i < p.size(); ++i) { // if (j < S.size() && S[j] == p[i]) { // ++j; // } else if (S[0] == p[i]) { // j = 1; // } else { // j = 0; // } // coins = max(coins, j); // } // cout<<p.size()<<' '<<S.size()*4<<' '<<coins<<endl; // return coins; // } string guess_sequence(int N){ string tmp = "ABXY"; string done = ""; // first letter if(press("AB") >= 1){ if(press("A") >= 1){ done += "A"; tmp = "BXY"; } else { done += "B"; tmp = "AXY"; } } else { if(press("X") >= 1){ done += "X"; tmp = "ABY"; } else { done += "Y"; tmp = "ABX"; } } while(done.size() < N-1){ int exp = done.size()+1; string query = done + tmp[0] + done + tmp[1] + tmp[0] + done + tmp[1] + tmp[1] + done + tmp[1] + tmp[2]; int q = press(query); if(q == exp){ done += tmp[0]; } else if(q == exp+1){ done += tmp[1]; } else { done += tmp[2]; } } string query = done + tmp[0]; if(press(query) == N){ done += tmp[0]; return done; } query = done + tmp[1]; if(press(query) == N){ done += tmp[1]; return done; } done += tmp[2]; return done; } // signed main() { // ios_base::sync_with_stdio(false); // cin.tie(NULL); // // #ifdef LOCAL // // freopen("input.txt", "r", stdin); // // #endif // cin>>S; // cout<<guess_sequence(S.size())<<endl; // return 0; // }

Compilation message (stderr)

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