Submission #380431

#TimeUsernameProblemLanguageResultExecution timeMemory
380431Dan4Life콤보 (IOI18_combo)C++17
100 / 100
54 ms584 KiB
#include <bits/stdc++.h>
#include "combo.h"
using namespace std;

string guess_sequence(int N) {
  string p = "AB", temp = "ABXY", x = "";
  if(!press(p))p="XY";
  if(!press(p.substr(0,1)))p=p[1];
  else p = p[0];
  for(auto u : temp) if(p[0]!=u)x+=u;
  for(int i = 1; i < N-1; i++)
  {
      int num = press(p+x[0]+p+x[1]+x[0]+p+x[1]+x[1]+p+x[1]+x[2]);
      if(num==p.size()) p+=x[2];
      else if(num==p.size()+1)p+=x[0];
      else p+=x[1];
  }
  if(N>1 and press(p+x[0]+p+x[1])==p.size())p+=x[2];
  else if(N>1 and press(p+x[0])==p.size()+1)p+=x[0];
  else if(N>1) p+=x[1];
  return p;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:14:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |       if(num==p.size()) p+=x[2];
      |          ~~~^~~~~~~~~~
combo.cpp:15:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |       else if(num==p.size()+1)p+=x[0];
      |               ~~~^~~~~~~~~~~~
combo.cpp:18:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |   if(N>1 and press(p+x[0]+p+x[1])==p.size())p+=x[2];
      |              ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
combo.cpp:19:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |   else if(N>1 and press(p+x[0])==p.size()+1)p+=x[0];
      |                   ~~~~~~~~~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...