Submission #716601

#TimeUsernameProblemLanguageResultExecution timeMemory
716601TahirAliyevCombo (IOI18_combo)C++17
0 / 100
1 ms264 KiB
#include "combo.h"
#include <bits/stdc++.h>

using namespace std;

string guess_sequence(int N) {
    string ans = "";
    if(press("AB") == 1){
        if(press("A") == 1){
          ans += 'A';
        }
        else{
          ans += 'B';
        }
    }
    else{
        if(press("X") == 1){
          ans += 'X';
        }
        else{
          ans += 'Y';
        }
    }
    if(N == 1) return ans;
    vector<char> v = {'A', 'B', 'X', 'Y'};
    v.erase(find(v.begin(), v.end(), ans[0]));

    for (int i = 2; i < N; i++)
    {
        string help = "";
        help += ans;
        help += v[0];
        for (int j = 0; j < 3; j++)
        {
            help += ans;
            help += v[1];
            help += v[j];
        }
        int coins = press(help);
        if(coins == ans.size() + 1){
            ans += v[0];
        }
        else if(coins == ans.size() + 2){
            ans += v[1];
        }
        else{
            ans += v[2];
        }
    }
    if(press(ans + v[0]) == N){
        ans += v[0];
    }else if(press(ans + v[1]) == N){
        ans += v[1];
    }
    else{
        ans += v[2];
    }
    return ans;
}

Compilation message (stderr)

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