제출 #139902

#제출 시각아이디문제언어결과실행 시간메모리
139902vince콤보 (IOI18_combo)C++14
5 / 100
2 ms344 KiB
#include "combo.h"
#include <stdio.h>
#include <iostream>
#include <string>
#include <assert.h>

using namespace std;

string C;

string guess_sequence(int N) 
{
    string S = "";
    int a = press("AX");

    if(a)
    {
        int x = press("A");
        if(x) S = "A", C = "BXY";
        else S = "X", C = "ABY";
    }
    else 
    {
        int x = press("B");
        if(x) S = "B", C = "AXY";
        else S = "Y", C = "ABX";
    }

    while(1)
    {
        string T = S + C.substr(0,1);
        for(int i = 0; i < 3; i++)
        {
            T += S + C.substr(1,1) + C.substr(i, 1);
        }
        if(T.size() > 4*N)
        {
            assert(0);
        }
        int val = press(T);
        if(val == S.size()+1)
            S += C.substr(0,1);
        else if(val == S.size()+2)
            S += C.substr(1,1);   
        else
            S += C.substr(2,1);

        // cout << S << "\n";
        if(S.size() == N-1)
            break;
    }
    string T = S + C.substr(0,1) + S + C.substr(1,1);
    if(T.size() > 4*N)
    {
          assert(0);
     }
    int x = press(T);
    
    if(x == N)
    {
        if(T.size() > 4*N)
        {
            assert(0);
        }
        if(press(S + C.substr(0,1)) == N)
            return S + C.substr(0,1);
        else return S + C.substr(1,1);
    }
    else return S + C.substr(2,1);

    
    return S;
}

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:36:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   36 |         if(T.size() > 4*N)
      |            ~~~~~~~~~^~~~~
combo.cpp:41:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |         if(val == S.size()+1)
      |            ~~~~^~~~~~~~~~~~~
combo.cpp:43:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |         else if(val == S.size()+2)
      |                 ~~~~^~~~~~~~~~~~~
combo.cpp:49:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   49 |         if(S.size() == N-1)
      |            ~~~~~~~~~^~~~~~
combo.cpp:53:17: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   53 |     if(T.size() > 4*N)
      |        ~~~~~~~~~^~~~~
combo.cpp:61:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   61 |         if(T.size() > 4*N)
      |            ~~~~~~~~~^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...