Submission #589331

#TimeUsernameProblemLanguageResultExecution timeMemory
589331PoonYaPatCombo (IOI18_combo)C++14
100 / 100
33 ms524 KiB
#include "combo.h"
//#include "grader.cpp";
#include <bits/stdc++.h>
using namespace std;

//int press()

string guess_sequence(int N) {
    string ans,first;

    if (press("AB")>=1) {
        if (press("A")==1) first="A";
        else first="B";
    } else {
        if (press("X")==1) first="X";
        else first="Y";
    }
    ans+=first;

    vector<string> lt; //A,B,X
    if (first!="A") lt.push_back("A");
    if (first!="B") lt.push_back("B");
    if (first!="X") lt.push_back("X");
    if (first!="Y") lt.push_back("Y");

    for (int i=1; i<N-1; ++i) {
        int cnt=press(ans+lt[0]+lt[0]+ans+lt[0]+lt[1]+ans+lt[0]+lt[2]+ans+lt[1]);
        int sz=ans.size();

        if (cnt==sz) ans+=lt[2];
        else if (cnt==sz+1) ans+=lt[1];
        else ans+=lt[0];
    }

    if (N>1) {
        if (press(ans+lt[1]+ans+lt[2])==ans.size()+1) {
            if (press(ans+lt[1])==ans.size()+1) ans+=lt[1];
            else ans+=lt[2];
        } else ans+=lt[0];
    }

    return ans;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:36:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |         if (press(ans+lt[1]+ans+lt[2])==ans.size()+1) {
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
combo.cpp:37:33: 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 (press(ans+lt[1])==ans.size()+1) ans+=lt[1];
      |                 ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...