Submission #261787

#TimeUsernameProblemLanguageResultExecution timeMemory
261787yabsedCombo (IOI18_combo)C++17
100 / 100
41 ms676 KiB
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;

string guess_sequence(int N) {
    char crr[]={'A', 'B', 'X', 'Y'};
    char wow[N+5];
    vector <char> cr;
    string S;
    for(int i=0;i<N;i++){
        //crr[i]=-1;
        if(!i){
            string p="";
            p+='A';
            p+='B';
            int conis=press(p);
            if(conis){
                string pp="";
                pp='A';
                conis=press(pp);
                if(conis)wow[0]='A';
                else wow[0]='B';
            }
            else{
                string pp="";
                pp='Y';
                conis=press(pp);
                if(conis)wow[0]='Y';
                else wow[0]='X';
            }

            //printf("%c", wow[0]);
            for(int j=0;j<4;j++){
                //printf("\n%d %d\n", wow[0], crr[j]);
                if(wow[0]!=crr[j])
                    cr.push_back(crr[j]);
            }
        }
         else if(N-1==i){
            //printf("%d\n", cr.size());
            wow[i]=cr[0];
            for(int j=1;j<cr.size();j++){
                string p=S;
                //std::cout << S << std::endl;
                p+=cr[j];
                //std::cout << p << std::endl;
                //pri
                //printf("%s\n", p);
                int coins=press(p);
                if(coins==i+1){
                    wow[i]=cr[j];
                }
            }
        }
        else{
            string p;
            for(int j=0;j<3;j++){
                p+=S; p+=cr[2]; p+=cr[j];
            }
            p+=S; p+=cr[1];
            //std::cout << S << std::endl;
            int coins=press(p);
            //printf("%d\n", coins);
            for(int j=0;j<3;j++){
                if(coins==i+j)
                    wow[i]=cr[j];
            }
        }
        S+=wow[i];
    }
    return S;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:42:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |             for(int j=1;j<cr.size();j++){
      |                         ~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...