Submission #647637

#TimeUsernameProblemLanguageResultExecution timeMemory
647637TruitadepatatesCombo (IOI18_combo)C++14
100 / 100
43 ms596 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; const int M = 4; const char A[] = "ABXY"; int guess_one(const string& s) { int len = press(s + A[0] + s + A[1]); int idx = 2*(len < s.length()+1); len = press(s + A[idx]); idx += (len < s.length()+1); return idx; } string guess_sequence(int N) { int idx[M]; for (int i = 0; i < M; i++) { idx[i] = i; } string s; int id = guess_one(s); s += A[id]; swap(idx[id], idx[M-1]); for (int i = 0; i < N-2; i++) { string z; for (int j = 0; j < M-1; j++) { z += s + A[idx[0]] + A[idx[j]]; } z += s + A[idx[1]]; int len = press(z); if (len == i+3) { s += A[idx[0]]; } else if (len == i+2) { s += A[idx[1]]; } else { s += A[idx[2]]; } } if (N > 1) { int id = guess_one(s); s += A[id]; } return s; }

Compilation message (stderr)

combo.cpp: In function 'int guess_one(const string&)':
combo.cpp:10:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |   int idx = 2*(len < s.length()+1);
      |                ~~~~^~~~~~~~~~~~~~
combo.cpp:12:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |   idx += (len < s.length()+1);
      |           ~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...