제출 #831374

#제출 시각아이디문제언어결과실행 시간메모리
831374MularstyleCombo (IOI18_combo)C++14
91 / 100
27 ms620 KiB
#include "combo.h"
#include<bits/stdc++.h>
using namespace std;


std::string guess_sequence(int n) {

    string S;
    string a;

    ///FIRST DIGIT
    if(press("A")==1)
        S="A",a="BXY";
    else if(press("B")==1)
        S="B",a="AXY";
    else if(press("X")==1)
        S="X",a="ABY";
    else
        S="Y",a="ABX";

    if(n==1)
        return S;

    ///MIDDLE
    int cur=1;
    while(S.length()<n-1)
    {
        int t=press(S+a[0]+S+a[1]+a[0]+S+a[1]+a[1]+S+a[1]+a[2]);
        if(t==cur+1)
            S+=a[0];
        else if(t==cur+2)
            S+=a[1];
        else
            S+=a[2];
        cur++;
    }

    ///FIND LAST DIGIT
    if(press(S+"A")==n)
        S+="A";
    else if(press(S+"B")==n)
        S+="B";
    else if(press(S+"X")==n)
        S+="X";
    else if(press(S+"Y")==n)
        S+="Y";
    return S;
}

컴파일 시 표준 에러 (stderr) 메시지

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:26:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   26 |     while(S.length()<n-1)
      |           ~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...