Submission #138162

#TimeUsernameProblemLanguageResultExecution timeMemory
138162andremfqCombo (IOI18_combo)C++17
5 / 100
3047 ms200 KiB
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;
 
const int MAXN=2e3+5;
string atual, respf;
char opt[3];
int n;
 
std::string guess_sequence(int N) {
  if(N  != 3) while(1);
  n=N;
  atual="AB";
  if(press(atual)) {
    atual="A";
    if(press(atual)) respf=atual;
    else respf="B";
  }
  else {
    atual="X";
    if(press(atual)) respf=atual;
    else respf="Y";
  }
  opt[0]='A'; opt[1]='B'; opt[2]='X';
  for(int i=0; i<3; i++) if(opt[i]==respf[0]) opt[i]='Y';
 
  // cout << respf;
 
  while(respf.size()<n-1) {
    atual=respf;
    atual+=opt[1];
    atual+=(respf+opt[2]+opt[0]);
    atual+=(respf+opt[2]+opt[1]);
    atual+=(respf+opt[2]+opt[2]);
    // cout << "press " << atual << endl;
    int val=press(atual);
    if(val==respf.size()) respf+=opt[0];
    else if(val==respf.size()+1) respf+=opt[1];
    else respf+=opt[2];
  }
 
  int val=press(respf+opt[0]+respf+opt[1]);
  if(val>respf.size()) {
    val=press(respf+opt[0]);
    if(val>respf.size()) respf+=opt[0];
    else respf+=opt[1];
  }
  else {
    respf+=opt[2];
  }
 
  // cout << respf;
 
  return respf;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:29:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   29 |   while(respf.size()<n-1) {
      |         ~~~~~~~~~~~~^~~~
combo.cpp:37:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |     if(val==respf.size()) respf+=opt[0];
      |        ~~~^~~~~~~~~~~~~~
combo.cpp:38:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     else if(val==respf.size()+1) respf+=opt[1];
      |             ~~~^~~~~~~~~~~~~~~~
combo.cpp:43:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |   if(val>respf.size()) {
      |      ~~~^~~~~~~~~~~~~
combo.cpp:45:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |     if(val>respf.size()) respf+=opt[0];
      |        ~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...