Submission #501336

#TimeUsernameProblemLanguageResultExecution timeMemory
501336shantolCombo (IOI18_combo)C++14
100 / 100
39 ms508 KiB
#include <bits/stdc++.h>
#include "combo.h"
using namespace std;


string guess_sequence(int N){
    string a;
    char x,y,z;
    for(int i=0;i<N;i++){
        if(i==0){
            if(press("AB")){
                if(press("A")){
                    a="A";
                    x='B';
                    y='X';
                    z='Y';
                }
                else {
                    a="B";
                    x='A';
                    y='X';
                    z='Y';
                }
            }
            else if(press("X")){
                a="X";
                x='B';
                y='A';
                z='Y';
            }
            else {
                a="Y";
                x='B';
                y='X';
                z='A';
            }

        }
        else if(i==N-1){
            if(press(a+x)==i+1){a+=x;}
            else if(press(a+y)==i+1){a+=y;}
            else {a+=z;}
        }
        else{
            int p=press(a+x+x+a+x+y+a+x+z+a+y);
            if(p==i+2){a+=x;}
            else if(p==i+1){a+=y;}
            else {a+=z;}
        }
    }
    return a;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:41:29: warning: 'y' may be used uninitialized in this function [-Wmaybe-uninitialized]
   41 |             else if(press(a+y)==i+1){a+=y;}
      |                             ^
combo.cpp:40:24: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
   40 |             if(press(a+x)==i+1){a+=x;}
      |                        ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...