제출 #624322

#제출 시각아이디문제언어결과실행 시간메모리
624322speedyArdaCombo (IOI18_combo)C++14
0 / 100
0 ms208 KiB
#include "combo.h"
#include "bits/stdc++.h"
using namespace std;
string letters[4] = {"A", "B", "X", "Y"}; 

string guess_sequence(int N) {
  string res = "";
    int forbidden;
    for(int idx = 0; idx < 3; idx++)
    {
        string i = letters[idx];
        int num = press(i);
        if(num == 1)
        {
            res = i;
            forbidden  = idx;
            break;
        }
    }  
    if(res.size() == 0) {
        res = "Y";  
        forbidden = 3;
    }
    string available[3];
    for(int i = 0; i < 4; i++)
    {
        if(forbidden == i)
            continue;
        if(i < forbidden)
            available[i] = letters[i];
        else 
            available[i - 1] = letters[i];
    }
    while(res.size() < N)
    {
        int curr = 0;
        string temp = "";
        for(int i = 0; i <= 2; i++)
        {
            temp += res + available[0] + available[i];
        }
        temp += res + available[1];
        int num = press(temp);
        if(num == res.size())
            res += available[2];
        else if(num - 1 == res.size())
            res += available[1];
        else
            res += available[0];

    }
    return res;
}

컴파일 시 표준 에러 (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 |     while(res.size() < N)
      |           ~~~~~~~~~~~^~~
combo.cpp:44:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |         if(num == res.size())
      |            ~~~~^~~~~~~~~~~~~
combo.cpp:46:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |         else if(num - 1 == res.size())
      |                 ~~~~~~~~^~~~~~~~~~~~~
combo.cpp:36:13: warning: unused variable 'curr' [-Wunused-variable]
   36 |         int curr = 0;
      |             ^~~~
combo.cpp:29:9: warning: 'forbidden' may be used uninitialized in this function [-Wmaybe-uninitialized]
   29 |         if(i < forbidden)
      |         ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...