Submission #580491

#TimeUsernameProblemLanguageResultExecution timeMemory
580491VanillaCombo (IOI18_combo)C++17
5 / 100
1 ms336 KiB
#include <bits/stdc++.h>
#include "combo.h"
using namespace std;
string ord = "ABXY";

string guess_sequence(int N) {
  int a1 = press("AB");
  int fr = 0;
  if (a1 == 0) {
    fr = 2;
    int a2 = press("X");
    if (!a2) fr = 3;
  }
  else if (a1 == 1) {
    int a2 = press("A");
    if (!a2) fr = 1;
  }
  if (fr == 1) ord = "BXYA";
  else if (fr == 2) ord = "XYAB";
  else if (fr == 3) ord = "YABX";
  string rs = "";
  rs.push_back(ord[0]);
  if (N == 1) return rs;
  for (int i = 1; i < N - 1; i++){
    string nw = rs + ord[1] + rs + ord[2] + ord[1] + rs + ord[2] + ord[2] + rs + ord[2] + ord[3];
    assert(nw.size() <= 4 * N);
    int now = press(nw);
    if (now == rs.size() + 1) {
      rs+=ord[1];
    }
    else if (now == rs.size() + 2) {
      rs+=ord[2];
    }
    else {
      rs+=ord[3];
    }
  }
  if (press(rs + ord[1]) == N){
    if (press(rs + ord[2] + ord[1] + rs + ord[2] + ord[2] + rs + ord[2] + ord[3]) == N) rs.push_back(ord[2]);
    else rs.push_back(ord[1]);
  } 
  else {
    if (press(rs + ord[2] + ord[1] + rs + ord[2] + ord[2] + rs + ord[2] + ord[3]) == N) rs.push_back(ord[2]);
    else rs.push_back(ord[3]);
  }
  // cout << rs << "\n";
  return rs;
}

Compilation message (stderr)

In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from combo.cpp:1:
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:26:22: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   26 |     assert(nw.size() <= 4 * N);
      |            ~~~~~~~~~~^~~~~~~~
combo.cpp:28:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |     if (now == rs.size() + 1) {
      |         ~~~~^~~~~~~~~~~~~~~~
combo.cpp:31:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     else if (now == rs.size() + 2) {
      |              ~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...