Submission #589325

#TimeUsernameProblemLanguageResultExecution timeMemory
589325PoonYaPatCombo (IOI18_combo)C++14
5 / 100
1 ms208 KiB
#include "combo.h"

#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 (auto s : lt) cout<<s<<" ";
    //cout<<"\n";

    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();

        //cout<<ans<<" "<<ans+lt[0]+lt[0]+ans+lt[0]+lt[1]+ans+lt[0]+lt[2]+ans+lt[1]<<" "<<cnt;

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

        //cout<<"\n";
    }

    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];

    //cout<<ans<<"\n";
    return ans;
}

Compilation message (stderr)

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