Submission #79040

# Submission time Handle Problem Language Result Execution time Memory
79040 2018-10-10T20:30:15 Z reda Combo (IOI18_combo) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
 
char c[4] = {'A', 'B', 'X', 'Y'};
 
string guess_sequence(int n)
{
  string pref;
 
  int t = press("AB");
 
  if(t > 0)
  {
    int a = press("A");
 
    if(a == 1) pref = "A";
 
    else pref = "B";
  }
 
  else
  {
    int a = press("X");
 
    if(a == 1) pref = "X";
 
    else pref = "Y";
  }
 
  if(pref.empty()) pref.push_back(c[3]);
 
  for(int i = 0; i < 4; i++)
    if(c[i] == pref[0]) swap(c[i], c[0]);
 
  for(int j = 0; j < n - 2; j++)
  {
    string aux = pref + c[1] + pref + c[2] + c[3] + pref + c[2] + c[1] + pref + c[2] + c[2];
 
    int ans = press(aux);
 
    if(ans == pref.size() + 1) pref.push_back(c[1]);
 
    else if(ans == pref.size() + 2) pref.push_back(c[2]);
 
    else pref.push_back(c[3]);
  }
 
  if(n != 1)
  {
    for(int i = 1; i < 3; i++)
    {
      string aux = pref + c[i];
 
      if(press(aux) == pref.size() + 1)
      {
        return aux;
      }
    }
 
    pref += c[3];
  }
 
  return pref;
}

Compilation message

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:11:11: error: 'press' was not declared in this scope
   11 |   int t = press("AB");
      |           ^~~~~
combo.cpp:42:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |     if(ans == pref.size() + 1) pref.push_back(c[1]);
      |        ~~~~^~~~~~~~~~~~~~~~~~
combo.cpp:44:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |     else if(ans == pref.size() + 2) pref.push_back(c[2]);
      |             ~~~~^~~~~~~~~~~~~~~~~~