Submission #648123

#TimeUsernameProblemLanguageResultExecution timeMemory
648123d4xnCombo (IOI18_combo)C++17
5 / 100
2 ms464 KiB
#include "combo.h"
 
#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
using namespace std;
 
#define pb push_back
 
string guess_sequence(int N) {
  string p;
 
  string dict1 = "ABXY";
 
  assert(p.size() == 0);
  int x = press("AB");
  if (x >= 1) {
    if (press("A")) {
      p.pb('A');
    }
    else {
      p.pb('B');
    }
  }
  else {
    if (press("X")) {
      p.pb('X');
    }
    else {
      p.pb('Y');
    }
  }
  assert(p.size() == 1);
 
  string dict2;
  for (char &c : dict1) {
    if (c == p[0]) continue;
    dict2.pb(c);
  }
 
  assert(p.size() == 1);
  for (int i = 1; i < N-1; i++) {
    int y = press(p+dict2[0] + p+dict2[1]+dict2[0] + p+dict2[1]+dict2[1] + p+dict2[1]+dict2[2]);
    if (y == i+1) {
      p.pb(dict2[0]);
    }
    else if (y == i+2) {
      p.pb(dict2[1]);
    }
    else {
      p.pb(dict2[2]);
    }
  }
 
  assert(p.size() == N-1);
  for (int i = 0; i < 2; i++) {
    char c = dict2[i];
    p.pb(c);
    if (press(p) == N) break;
    p.pop_back();
  }
 
  if (p.size() < N) {
    p.pb(dict2[2]);
  }
  assert(p.size() == N);
 
  return p;
}

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:4:
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:54:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   54 |   assert(p.size() == N-1);
      |          ~~~~~~~~~^~~~~~
combo.cpp:62:16: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   62 |   if (p.size() < N) {
      |       ~~~~~~~~~^~~
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:4:
combo.cpp:65:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   65 |   assert(p.size() == N);
      |          ~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...