Submission #154666

#TimeUsernameProblemLanguageResultExecution timeMemory
154666rama_pangCombo (IOI18_combo)C++14
100 / 100
56 ms568 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; string guess_sequence(int N) { if (N == 1) { if (press("A") == 1) return "A"; if (press("B") == 1) return "B"; if (press("X") == 1) return "X"; return "Y"; } string cur = ""; int tmp; tmp = press("AB"); if (tmp >= 1) { tmp = press("A"); if (tmp == 1) cur = "A"; else cur = "B"; } else { tmp = press("X"); if (tmp == 1) cur = "X"; else cur = "Y"; } vector<char> ls; if (cur[0] != 'A') ls.push_back('A'); if (cur[0] != 'B') ls.push_back('B'); if (cur[0] != 'X') ls.push_back('X'); if (cur[0] != 'Y') ls.push_back('Y'); while (cur.size() < N - 1) { string guess; guess = cur + ls[0] + cur + ls[1] + ls[0] + cur + ls[1] + ls[1] + cur + ls[1] + ls[2]; tmp = press(guess); if (tmp == cur.size()) { cur.push_back(ls[2]); } else if (tmp == cur.size() + 1) { cur.push_back(ls[0]); } else { cur.push_back(ls[1]); } } tmp = press(cur + ls[0]); if (tmp == N) { cur.push_back(ls[0]); } else { tmp = press(cur + ls[1]); if (tmp == N) cur.push_back(ls[1]); else cur.push_back(ls[2]); } return cur; }

Compilation message (stderr)

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