제출 #86941

#제출 시각아이디문제언어결과실행 시간메모리
86941tjdgus4384콤보 (IOI18_combo)C++14
100 / 100
52 ms524 KiB
#include<cstdio>
#include "combo.h"
#include<string>
#include<iostream>
using namespace std;
string x[4] = {"A", "B", "X", "Y"};

string guess_sequence(int n)
{
    string ans, s;
    int f;
    if(press("AB"))
    {
        if(press("A")) f = 0;
        else f = 1;
    }
    else
    {
        if(press("X")) f = 2;
        else f = 3;
    }
    ans = x[f];
    for(int i = 0;i < 4;i++)
    {
        if(i == f) continue;
        s += x[i];
    }
    for(int i = 2;i < n;i++)
    {
        string p = ans + s[0] + s[0] + ans + s[0] + s[1] + ans + s[0] + s[2] + ans + s[1];
        int res = press(p);
        if(res == ans.length() + 2) ans += s[0];
        else if(res == ans.length() + 1) ans += s[1];
        else ans += s[2];
    }
    if(n > 1){
        if(press(ans + s[0]) == n) ans += s[0];
        else if(press(ans + s[1]) == n) ans += s[1];
        else ans += s[2];
    }
    return ans;
}

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:32:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |         if(res == ans.length() + 2) ans += s[0];
      |            ~~~~^~~~~~~~~~~~~~~~~~~
combo.cpp:33:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |         else if(res == ans.length() + 1) ans += s[1];
      |                 ~~~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...