Submission #96129

#TimeUsernameProblemLanguageResultExecution timeMemory
96129kitsu_hiCombo (IOI18_combo)C++14
0 / 100
2 ms200 KiB
#include "combo.h"
#include <bits/stdc++.h> 
using namespace std;

string guess_sequence(int N) {
  string ans;
  ans.clear();
  if ( press("AB") ) {
    if ( press("A") ) ans += 'A';
    else ans += 'B';
  }
  else {
    if ( press("X") ) ans += 'X';
    else ans += 'Y';
  }
  if ( N == 1 )  return ans;

  set<char> c_;
  char c[4];
  c_.insert('A');
  c_.insert('B');
  c_.insert('X');
  c_.insert('Y');
  c_.erase('ans[0]');
  auto it = c_.begin();
  for ( int i = 1; i <= 3; i++ ) {
    c[i] = *it;
    it++; 
  }
  
  for ( int j = 2 ; j < N; j++ ) {
    string ct;
    ct.clear();
    for ( int i = 1; i <= 3; i++ ) {
      ct = ct + ans + c[1] + c[i];
    }
    ct = ct + ans + c[2];
    int x = press(ct);
    if ( x == j - 1) ans += c[3];
    if ( x == j ) ans += c[2];
    if ( x == j + 1 ) ans += c[1];
  }
  
  if ( press( ans + c[1] + ans + c[2] ) == N ) {
    if ( press( ans + c[1]) == N ) ans += c[1];
    else ans += c[2];
  }
  else {
    ans += c[3];
  }
  return ans;
}

Compilation message (stderr)

combo.cpp:24:12: warning: character constant too long for its type
   24 |   c_.erase('ans[0]');
      |            ^~~~~~~~
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:24:12: warning: overflow in conversion from 'int' to 'std::set<char>::key_type' {aka 'char'} changes value from '1935355997' to '93' [-Woverflow]
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...