Submission #284296

#TimeUsernameProblemLanguageResultExecution timeMemory
284296MKopchevCombo (IOI18_combo)C++14
100 / 100
43 ms664 KiB
#include "combo.h"
#include<bits/stdc++.h>
using namespace std;

string guess_sequence(int N)
{
    string start="";

    if(press("AB"))
    {
        if(press("A"))start="A";
        else start="B";
    }
    else
    {
        if(press("X"))start="X";
        else start="Y";
    }

    if(N==1)return start;

    string other="";

    if(start[0]!='A')other.push_back('A');
    if(start[0]!='B')other.push_back('B');
    if(start[0]!='X')other.push_back('X');
    if(start[0]!='Y')other.push_back('Y');

    for(int i=2;i<N;i++)
    {
        //cout<<"start= "<<start<<endl;

        string cur=start;

        cur.push_back(other[0]);

        cur=cur+start;
        cur.push_back(other[1]);
        cur.push_back(other[0]);

        cur=cur+start;
        cur.push_back(other[1]);
        cur.push_back(other[1]);

        cur=cur+start;
        cur.push_back(other[1]);
        cur.push_back(other[2]);

        int val=press(cur);

        if(val==start.size())start.push_back(other[2]);
        else if(val==start.size()+1)start.push_back(other[0]);
        else start.push_back(other[1]);
    }

    string cur;

    cur=start;
    cur.push_back(other[0]);
    if(press(cur)==N)return cur;

    cur=start;
    cur.push_back(other[1]);
    if(press(cur)==N)return cur;

    cur=start;
    cur.push_back(other[2]);
    return cur;
}

Compilation message (stderr)

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