Submission #102454

#TimeUsernameProblemLanguageResultExecution timeMemory
102454muradeynCombo (IOI18_combo)C++14
100 / 100
48 ms572 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; string guess_sequence(int N) { string res; vector<char>v; if (press("AB") >= 1) { if (press("A") == 1)res = "A"; else res = "B"; } else { if (press("X") == 1)res = "X"; else res = "Y"; } if (res[0] != 'X')v.push_back('X'); if (res[0] != 'Y')v.push_back('Y'); if (res[0] != 'A')v.push_back('A'); if (res[0] != 'B')v.push_back('B'); while (res.length() < N) { if (res.length() == N - 1) { if (press(res + v[0]) == N)res += v[0]; else if (press(res + v[1]) == N)res += v[1]; else res += v[2]; continue; } string query = res + v[0] + res + v[1] + v[0] + res + v[1] + v[1] + res + v[1] + v[2]; //cout<<query<<endl; int val = press(query); //cout<<val<<endl; if (val == res.length()+2)res += v[1]; else if (val == res.length()+1)res += v[0]; else res += v[2]; } return res; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:21:25: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   21 |     while (res.length() < N) {
      |            ~~~~~~~~~~~~~^~~
combo.cpp:22:26: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   22 |         if (res.length() == N - 1) {
      |             ~~~~~~~~~~~~~^~~~~~~~
combo.cpp:32:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |         if (val == res.length()+2)res += v[1];
      |             ~~~~^~~~~~~~~~~~~~~~~
combo.cpp:33:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |         else if (val == res.length()+1)res += v[0];
      |                  ~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...