제출 #613985

#제출 시각아이디문제언어결과실행 시간메모리
613985FETTCombo (IOI18_combo)C++14
100 / 100
36 ms644 KiB
#include "combo.h"
#include "bits/stdc++.h"

using namespace std;

string guess_sequence(int N)
{
    string p = "";
    string S = "";
    int coin;
    char rest[3];
    coin=press("AB");
    if(coin==0)
    {
        coin=press("Y");
        if(coin==1)
        {
            S+='Y';
            //rest={'A','B','X'};
            rest[0]='A';
            rest[1]='B';
            rest[2]='X';
        }else{
            S+='X';
            //rest={'A','B','Y'};
            rest[0]='A';
            rest[1]='B';
            rest[2]='Y';
        }
    }else{
        coin=press("A");
        if(coin==1)
        {
            S+='A';
            //rest={'Y','B','X'};
            rest[0]='Y';
            rest[1]='B';
            rest[2]='X';
        }else{
            S+='B';
            //rest={'A','Y','X'};
            rest[0]='A';
            rest[1]='Y';
            rest[2]='X';
        }
    }

    while(S.length()<N-1)
    {
        p=S+rest[0]+S+rest[1]+rest[1]+S+rest[1]+rest[2]+S+rest[1]+rest[0];
        coin=press(p);
        if(coin==S.length()+1)
        {
            S+=rest[0];
        }
        else if(coin==S.length())
        {
            S+=rest[2];
        }
        else{
            S+=rest[1];
        }
    }
    if(S.length()==N-1)
    {
        p=S+rest[0]+S+rest[1];
        coin=press(p);
        if(coin==S.length())
        {
            S+=rest[2];
        }else{
            p=S+rest[0];
            coin=press(p);
            if(coin==S.length())
            {
                S+=rest[1];
            }else{
                S+=rest[0];
            }
        }
    }

    return S;
}

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:48:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   48 |     while(S.length()<N-1)
      |           ~~~~~~~~~~^~~~
combo.cpp:52:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |         if(coin==S.length()+1)
      |            ~~~~^~~~~~~~~~~~~~
combo.cpp:56:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |         else if(coin==S.length())
      |                 ~~~~^~~~~~~~~~~~
combo.cpp:64:18: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   64 |     if(S.length()==N-1)
      |        ~~~~~~~~~~^~~~~
combo.cpp:68:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   68 |         if(coin==S.length())
      |            ~~~~^~~~~~~~~~~~
combo.cpp:74:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   74 |             if(coin==S.length())
      |                ~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...