Submission #294602

#TimeUsernameProblemLanguageResultExecution timeMemory
294602AutoratchCombo (IOI18_combo)C++14
5 / 100
1 ms208 KiB
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;

string guess_sequence(int n) 
{
    string ans,ch = "ABXY",tmp;
    if(press("XY"))
    {
        if(press("X")) ans = "X";
        else ans = "Y";
    }
    else
    {
        if(press("A")) ans = "A";
        else ans = "B";
    }
    for(char c : ch) if(c!=ans[0]) tmp+=c;
    ch = tmp;
    for(int i = 1;i < n-1;i++)
    {
        tmp = ans+ch[0]+ch[0]+ans+ch[0]+ch[1]+ans+ch[0]+ch[2]+ans+ch[1];
        int ret = press(tmp);
        if(ret==ans.length()+2) ans+=ch[0];
        else if(ret==ans.length()+1) ans+=ch[1];
        else ans+=ch[2];
    }
    if(press(ans+ch[0])==n) return ans+ch[0];
    else if(press(ans+ch[1])==n) return ans+ch[1];
    else return ans+ch[2];
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:24:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |         if(ret==ans.length()+2) ans+=ch[0];
      |            ~~~^~~~~~~~~~~~~~~~
combo.cpp:25:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |         else if(ret==ans.length()+1) ans+=ch[1];
      |                 ~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...