Submission #95574

#TimeUsernameProblemLanguageResultExecution timeMemory
95574dantoh000Combo (IOI18_combo)C++14
100 / 100
53 ms712 KiB
#include <bits/stdc++.h>
using namespace std;
#include "combo.h"

string guess_sequence(int N) {
    char firstletter;
    string S = "";
    string p = "";
    char choices[3];
    if (press("AB") >= 1){
        if (press("A") == 1){
            firstletter = 'A';
        }
        else firstletter = 'B';
    }
    else {
        if (press("X") == 1){
            firstletter = 'X';
        }
        else firstletter = 'Y';
    }
    int cur = 0;
    if (firstletter != 'A') choices[cur++] = 'A';
    if (firstletter != 'B') choices[cur++] = 'B';
    if (firstletter != 'X') choices[cur++] = 'X';
    if (firstletter != 'Y') choices[cur++] = 'Y';
    S += firstletter;
    int curscore = 1;
    for (int i = 1; i < N-1; ++i) {
        p = S+choices[0] + choices[0] + S+choices[0]+choices[1]+S+choices[0]+choices[2]+S+choices[1];
        //cout << "guessing " << p << " size of " << N << " " << p.length() << endl;
        int score = press(p);
        if (score == curscore){
            S += choices[2];
        }
        else if (score == curscore+1){
            S += choices[1];
        }
        else {
            S += choices[0];
        }
        curscore++;
    }
    if (S.size() == N-1){
        p = S+choices[0] + S+choices[1];
        if (press(p) == N){
            p = S+choices[0];
            if (press(p) == N){
                S += choices[0];
            }
            else S += choices[1];
        }
        else S += choices[2];
    }
    return S;
}

Compilation message (stderr)

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