Submission #204389

#TimeUsernameProblemLanguageResultExecution timeMemory
204389my99nCombo (IOI18_combo)C++14
5 / 100
2 ms344 KiB
#include <bits/stdc++.h>
#include "combo.h"
using namespace std;

int n;
string ans;

char c[] = "ABXYABX";
int s = -10;
void g(string S1, string S2, string S3);
void f(string S) {
  if (n <= S.size()) return void (ans = S);
  assert(3*S.size()+6 <= 4*n);
  int coin = press(S+c[s+2]+c[s+2]+S+c[s+3]+c[s+3]+S+c[s+2]+c[s+1]);
  if (coin == S.size()) f(S+c[s+1]);
  if (coin == S.size()+1) g(S+c[s+2]+c[s+3], S+c[s+3]+c[s+2], S+c[s+3]+c[s+1]);
  if (coin == S.size()+2) g(S+c[s+3]+c[s+3], S+c[s+2]+c[s+2], S+c[s+2]+c[s+1]);
}
void g(string S1, string S2, string S3) {
  // cout << "g " << S1 << ' ' << S2 << ' ' << S3 << endl;
  // assert S1.size() == S2.size() == S3.size()
  int coin = press(S3);
  if (coin == S3.size()) f(S3);
  if (coin == S3.size()-1) f(S2);
  if (coin == S3.size()-2) f(S1);
}

string guess_sequence(int N) {
  n = N;
  string S = "";
  int a = press("AB");
  int b = press("AX");
  if (a and b) S = "A", s = 0;
  if (a and !b) S = "B", s = 1;
  if (!a and b) S = "X", s = 2;
  if (!a and !b) S = "Y", s = 3;
  f(S);
  // cout << ans << endl;
  string realans = "";
  for (int i = 0; i < n; i++) realans += ans[i];
  // cout << realans << endl;
  return realans;
}

Compilation message (stderr)

combo.cpp: In function 'void f(std::string)':
combo.cpp:12:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |   if (n <= S.size()) return void (ans = S);
      |       ~~^~~~~~~~~~~
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:13:23: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   13 |   assert(3*S.size()+6 <= 4*n);
      |          ~~~~~~~~~~~~~^~~~~~
combo.cpp:15:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |   if (coin == S.size()) f(S+c[s+1]);
      |       ~~~~~^~~~~~~~~~~
combo.cpp:16:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |   if (coin == S.size()+1) g(S+c[s+2]+c[s+3], S+c[s+3]+c[s+2], S+c[s+3]+c[s+1]);
      |       ~~~~~^~~~~~~~~~~~~
combo.cpp:17:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |   if (coin == S.size()+2) g(S+c[s+3]+c[s+3], S+c[s+2]+c[s+2], S+c[s+2]+c[s+1]);
      |       ~~~~~^~~~~~~~~~~~~
combo.cpp: In function 'void g(std::string, std::string, std::string)':
combo.cpp:23:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |   if (coin == S3.size()) f(S3);
      |       ~~~~~^~~~~~~~~~~~
combo.cpp:24:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |   if (coin == S3.size()-1) f(S2);
      |       ~~~~~^~~~~~~~~~~~~~
combo.cpp:25:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |   if (coin == S3.size()-2) f(S1);
      |       ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...