Submission #807634

#TimeUsernameProblemLanguageResultExecution timeMemory
807634kingfran1907Combo (IOI18_combo)C++14
100 / 100
29 ms576 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; std::string guess_sequence(int N) { string S; string ls; if (press("AB")) { if (press("A")) S = "A"; else S = "B"; } else { if (press("X")) S = "X"; else S = "Y"; } for (char t : "ABXY") { if (t != S[0]) ls.push_back(t); } ls.resize(3); //cout << ls.size() << endl; for (int i = 1; i < N - 1; i++) { string qs = S; qs.push_back(ls[0]); for (char t : ls) { qs += S; qs.push_back(ls[1]); qs.push_back(t); } //cout << "pressing: " << qs << endl; //for (char t : qs) printf("%c|", t); printf("\n"); int out = press(qs); if (out == S.size()) S.push_back(ls[2]); else if (out == S.size() + 1) S.push_back(ls[0]); else S.push_back(ls[1]); } for (int i = 0; i < 2; i++) { string qs = S; qs.push_back(ls[i]); qs.resize(N); if (press(qs) == N) return qs; } S.push_back(ls[2]); S.resize(N); return S; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:34:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |   if (out == S.size()) S.push_back(ls[2]);
      |       ~~~~^~~~~~~~~~~
combo.cpp:35:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |   else if (out == S.size() + 1) S.push_back(ls[0]);
      |            ~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...