제출 #200026

#제출 시각아이디문제언어결과실행 시간메모리
200026mohamedsobhi777Combo (IOI18_combo)C++14
30 / 100
66 ms420 KiB
#include "combo.h"
 
using namespace std;
 
std::string guess_sequence(int N) {
    string ret = "";
    string chs = "ABXY";
 
    if( press("XY") )
    {
        if(press("X"))ret = "X" , chs = "ABY";
        else ret = "Y" , chs = "ABX";
    }
    else
    {
        if(press("A"))ret = "A" , chs = "BXY";
        else ret = "B" , chs ="AXY";
    }
 
    for(int i = 1;i<N;i++)
    {
        bool ok = 0;
        for(int j = 0;j<2;j++)
        {
            string ask = ret;
            ask+=chs[j];
            if( press( ask ) ==i+1 )
            {
                ret+=chs[j];
                ok = 1;
                break;
            }
        }
        if(ret.size()==i)
            ret+=chs[2];
    }
    return ret;
}

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:34:22: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   34 |         if(ret.size()==i)
      |            ~~~~~~~~~~^~~
combo.cpp:22:14: warning: variable 'ok' set but not used [-Wunused-but-set-variable]
   22 |         bool ok = 0;
      |              ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...