Submission #835247

#TimeUsernameProblemLanguageResultExecution timeMemory
835247KemalKCombo (IOI18_combo)C++17
30 / 100
35 ms448 KiB
#include <bits/stdc++.h>
#include "combo.h"
using namespace std;

string guess_sequence(int n) {
  string s = "";
  string p = "";
  string cur = "ABXY";
  bool ok = false;
  for (int i = 0; i < 3; i++){
     p = cur[i];
     if (press(p)){
      ok = true;
      s += p;
      break;
     }
  }
  if (!ok){
    s = cur[3];
  }
  string rem = "";
  for (int i = 0; i < 4; i++){
    if (s[0] != cur[i]){
      rem += cur[i];
    }
  }
  int cnt = 1;
  while(s.size() != n){
    if (press(s + rem[0]) == cnt + 1){
      cnt++;
      s += rem[0];
    } 
    else if (press(s + rem[1]) == cnt + 1){
      cnt++;
      s += rem[1];
    }
    else{
      cnt++;
      s += rem[2];
    }
  }
  return s;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:28:18: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   28 |   while(s.size() != n){
      |         ~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...