Submission #295197

#TimeUsernameProblemLanguageResultExecution timeMemory
295197eohomegrownappsCombo (IOI18_combo)C++14
100 / 100
33 ms764 KiB
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;

//int press(string s)

string v[4] = {"A","B","X","Y"};

std::string guess_sequence(int N) {
    int n=N;
    
    string ans = "";

    // find first thing
    bool v01 = press(v[0]+v[1])==0;
    bool v02 = press(v[0]+v[2])==0;
    ans+=v[v01*2+v02];
    vector<string> use;
    for (int i = 0; i<4; i++){
        if (i==(v01*2+v02)){continue;}
        use.push_back(v[i]);
    }

    if (n==1){
        return ans;
    }

    for (int i = 2; i<=n-1; i++){
        string u00 = ans+use[0]+use[0];
        string u01 = ans+use[0]+use[1];
        string u02 = ans+use[0]+use[2];
        string u03 = ans+use[1];
        int c = press(u00+u01+u02+u03);
        if (c==ans.size()+2){
            ans+=use[0];
        } else if (c==ans.size()+1){
            ans+=use[1];
        } else if (c==ans.size()){
            ans+=use[2];
        } else {
            assert(1==0);
        }
    }

    if (press(ans+use[0])==ans.size()+1){
        return ans+use[0];
    }
    if (press(ans+use[1])==ans.size()+1){
        return ans+use[1];
    }
    return ans+use[2];
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:34:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |         if (c==ans.size()+2){
      |             ~^~~~~~~~~~~~~~
combo.cpp:36:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |         } else if (c==ans.size()+1){
      |                    ~^~~~~~~~~~~~~~
combo.cpp:38:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |         } else if (c==ans.size()){
      |                    ~^~~~~~~~~~~~
combo.cpp:45:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |     if (press(ans+use[0])==ans.size()+1){
      |         ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
combo.cpp:48:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |     if (press(ans+use[1])==ans.size()+1){
      |         ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...