Submission #719444

#TimeUsernameProblemLanguageResultExecution timeMemory
719444AndrijaMCombo (IOI18_combo)C++14
5 / 100
1 ms208 KiB
#include <bits/stdc++.h>
#include "combo.h"

using ll=long long;

using namespace std;


string guess_sequence(int n)
{
    vector<string>v;
    v.push_back("A");
    v.push_back("B");
    v.push_back("X");
    v.push_back("Y");
    string ans="";
    bool ok=false;
    string c="";
    if(!ok)
    {
        int kolku=press("AB");
        if(kolku==1)
        {
            if(press("A")==1)
            {
                ok=true;
                v.erase(v.begin()+0);
                c="A";
                ans+="A";
            }
            else
            {
                ok=true;
                v.erase(v.begin()+1);
                c="B";
                ans+="B";
            }
        }
        else if(kolku==2)
        {
                ok=true;
                v.erase(v.begin()+0);
                c="A";
                ans+="AB";
        }
        else
        {
            int kolku2=press("BX");
            if(kolku2==1)
            {
                ok=true;
                c="X";
                v.erase(v.begin()+2);
                ans+="X";
            }
            else if(kolku2==0)
            {
                ok=true;
                c="Y";
                v.erase(v.begin()+3);
                ans+="Y";
            }
        }
    }
    int k=1;
    while(true)
    {
        string nstr="";
        nstr+=ans+v[0]+ans+v[1]+v[0]+ans+v[1]+v[1]+ans+v[1]+v[2];
        if(nstr.size()<=4*n)
        {
            int kol=press(nstr);
            if(kol==k+1)
            {
                ans+=v[0];
            }
            else if(kol==k+2)
            {
                ans+=v[1];
            }
            else
            {
                ans+=v[2];
            }
        }
        else
        {
            if(n==1)
            {
                break;
            }
            if(press(ans+v[0])==n)
            {
                ans+=v[0];
                break;
            }
            if(press(ans+v[1])==n)
            {
                ans+=v[1];
                break;
            }
                ans+=v[2];
                break;
        }
        k=ans.size();
    }
    return ans;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:70:23: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   70 |         if(nstr.size()<=4*n)
      |            ~~~~~~~~~~~^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...