Submission #428572

#TimeUsernameProblemLanguageResultExecution timeMemory
428572EnkognitCombo (IOI18_combo)C++14
30 / 100
64 ms440 KiB
#include <bits/stdc++.h>
#include <vector>
#include "combo.h"
#define ll long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi first
#define se second

using namespace std;

string guess_sequence(int n) {
    vector<char> z={'A', 'B', 'X', 'Y'};
    string d;
    for (int i = 0; i < 2; i++) d+=z[i];
    string ans;
    ll p=press(d);
    if (p)
    {
        p=press("A");
        if (p)
        {
            ans+="A";
            z.erase(z.begin());
        }else
        {
            ans+="B";
            z.erase(z.begin()+1);
        }
    }else
    {
        p=press("X");
        if (p)
        {
            ans+="X";
            z.erase(z.begin()+2);
        }else
        {
            ans+="Y";
            z.erase(z.begin()+3);
        }
    }
    char lst='-';
    while (ans.size()<n)
    {
        for (int j = 0; j < z.size(); j++)
            if (lst!=z[j])
            {
                string d=ans;
                while (d.size()<n) d+=z[j];
                ll p=press(d);
                if (p>ans.size())
                {
                    while (ans.size()<p) ans+=z[j];
                    break;
                }
            }
        lst=ans.back();
    }
    return ans;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:46:22: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   46 |     while (ans.size()<n)
      |            ~~~~~~~~~~^~
combo.cpp:48:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |         for (int j = 0; j < z.size(); j++)
      |                         ~~^~~~~~~~~~
combo.cpp:52:32: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   52 |                 while (d.size()<n) d+=z[j];
      |                        ~~~~~~~~^~
combo.cpp:54:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |                 if (p>ans.size())
      |                     ~^~~~~~~~~~~
combo.cpp:56:38: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   56 |                     while (ans.size()<p) ans+=z[j];
      |                            ~~~~~~~~~~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...