Submission #648868

#TimeUsernameProblemLanguageResultExecution timeMemory
648868LitusianoCombo (IOI18_combo)C++14
5 / 100
29 ms496 KiB
#include<iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <string>
#include "combo.h"
using namespace std;

string guess_sequence(int N){
  string ans;
  int x = 1;
  if(press("AB") > 0){
    if(press("A")){
      ans+='A';
      x = 0;
    }
    else ans+='B';
  }
  else{
    if(press("X")){
      ans+='X';
      x = 2;
    }
    else{
      ans+='Y';
      x = 3;
    }
  }
  string all = "ABXY";
  string pos;
  for(int i = 0; i<all.size(); ++i){
    if(i == x) continue;
    pos+=all[i];
  }
  /*
  Faig una sola opcio amb 0
  dos opcions amb 1
  cap amb 2  
  */
  for(int i = 2; i<=N-2; ++i){
    string s0 = ans+pos[0];
    string s1 = ans+pos[1]+pos[0],s2 = ans+pos[1]+pos[1],s3 = ans+pos[1]+pos[2];
    string tot = s0+s1+s2+s3;
    //cout<<4*N<<" "<<tot.size()<<endl;
    int c = press(s0+s1+s2+s3);
    ans+=pos[(c-i)];
  }
  for(int i = max(2,N-1); i<=N; ++i){
    string tot = ans; tot+="A";
    tot+=ans; tot+="B";
    //cout<<tot<<" "<<press(tot)<<endl;
    if(press(tot) >= i){
      tot.pop_back();
      if(press(tot) >= i) ans+="A";
      else ans+="B";
    }
    else{
      tot = ans;
      tot+='X';
      if(press(tot) >= i) ans+="X";
      else ans+='Y';
    }
  }
  return ans;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:31:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |   for(int i = 0; i<all.size(); ++i){
      |                  ~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...