제출 #897351

#제출 시각아이디문제언어결과실행 시간메모리
897351honanhphongCombo (IOI18_combo)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define faster ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;
using lli = long long;
using ld = long double;
using pii = pair <int, int>;
mt19937_64 Rand(chrono::steady_clock::now().time_since_epoch().count());
const int maxn = 1e6 + 1000;
const int mod = 1e9 + 7;
int press(string p);



string guess_sequence(int N)
{
    string s = "";
    string p = "ABXY";
    char start;
    char cs[maxn];
    if(press("A"))res = "A";
    else if(press("B"))res = "B";
    else if(press("X"))res = "X";
    else res = "Y";
    if (res[0] == 'A')
    {
        cs[0] = 'B'; cs[1] = 'X'; cs[2] = 'Y';
    } else if (res[0] == 'B')
    {
        cs[0] = 'A'; cs[1] = 'X'; cs[2] = 'Y';
    } else if (res[0] == 'X')
    {
        cs[0] = 'A'; cs[1] = 'B'; cs[2] = 'Y';
    } else if (res[0] == 'Y')
    {
        cs[0] = 'A'; cs[1] = 'B'; cs[2] = 'X';
    }
    while (s.length() < N)
    {
        for (char c : p)
        {
            if (c == res[0]) continue;
            if (press(s + c) == s.size() + 1)
            {
                s += c;
                break;
            }
        }
    }
    return s;
}


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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:23:19: error: 'res' was not declared in this scope
   23 |     if(press("A"))res = "A";
      |                   ^~~
combo.cpp:24:24: error: 'res' was not declared in this scope
   24 |     else if(press("B"))res = "B";
      |                        ^~~
combo.cpp:25:24: error: 'res' was not declared in this scope
   25 |     else if(press("X"))res = "X";
      |                        ^~~
combo.cpp:26:10: error: 'res' was not declared in this scope
   26 |     else res = "Y";
      |          ^~~
combo.cpp:27:9: error: 'res' was not declared in this scope
   27 |     if (res[0] == 'A')
      |         ^~~
combo.cpp:40:23: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   40 |     while (s.length() < N)
      |            ~~~~~~~~~~~^~~
combo.cpp:44:22: error: 'res' was not declared in this scope
   44 |             if (c == res[0]) continue;
      |                      ^~~
combo.cpp:45:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |             if (press(s + c) == s.size() + 1)
      |                 ~~~~~~~~~~~~~^~~~~~~~~~~~~~~
combo.cpp:21:10: warning: unused variable 'start' [-Wunused-variable]
   21 |     char start;
      |          ^~~~~