제출 #572048

#제출 시각아이디문제언어결과실행 시간메모리
572048il9콤보 (IOI18_combo)C++17
5 / 100
1 ms208 KiB
//coding template
#include "combo.h"
#include <bits/stdc++.h>
using ll =long long;
using namespace std;

string guess_sequence(int n)
{

    string s;
    char f;
    long long temp=0;
    temp=press("XY");
    string no;
    if(temp==2)
    {
        f='X';
        no="YBA";
    }else if(temp==1)
    {
        temp=press("X");
        if(temp)
        {
            f='X';
            no="YBA";
        }else
        {
            f='Y';
            no="XBA";
        }
    }else
    {
        temp=press("B");
        if(temp)
        {
            f='B';
            no="XYA";
        }else
        {
            f='A';
            no="YXB";
        }
    }


    s=f;
    for(int i=0;i<n-2;i++)
    {
        temp=press(s+no[0]+s+no[1]+no[0]+s+no[1]+no[1]+s+no[1]+no[2]);
        if(temp==s.size()+1)
        {
            s+=no[0];
        }else if(temp==s.size())
        {
            s+=no[2];
        }else
        {
            s+=no[1];
        }
    }
    temp=press(s+no[0]+s+no[1]);
    if(temp==s.size())
    {
        s+=no[2];
    }else
    {
        temp=press(s+no[0]);
        if(temp==s.size()+1)
        {
            s+=no[0];
        }else
        {
            s+=no[1];
        }
    }
    return s;

}

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:50:16: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |         if(temp==s.size()+1)
      |            ~~~~^~~~~~~~~~~~
combo.cpp:53:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |         }else if(temp==s.size())
      |                  ~~~~^~~~~~~~~~
combo.cpp:62:12: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |     if(temp==s.size())
      |        ~~~~^~~~~~~~~~
combo.cpp:68:16: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   68 |         if(temp==s.size()+1)
      |            ~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...