제출 #1350906

#제출 시각아이디문제언어결과실행 시간메모리
1350906phungmanager0콤보 (IOI18_combo)C++20
컴파일 에러
0 ms0 KiB
#include "combo.h"
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; i++)
#define FORD(i, b, a) for (int i = (b), _a = (a); i >= _a; i--)
#define REP(i, n) for (int i = 0, _n = (n); i < _n; i++)
#define FORE(i, v) for (__typeof((v).begin()) i = (v).begin(); i != (v).end(); i++)
#define ALL(v) (v).begin(), (v).end()
#define IS_INF(x)   (std::isinf(x))
#define IS_NAN(x)   (std::isnan(x))
#define fi   first
#define se   second
#define MASK(i) (1LL << (i))
#define BIT(x, i) (((x) >> (i)) & 1)
#define div   ___div
#define prev   ___prev
#define next   ___next
#define left   ___leftc
#define right   ___right
#define TIME  (1.0 * clock() / CLOCKS_PER_SEC)
#define __Im_sogood__ main()
#define __builtin_popcount __builtin_popcountll
using namespace std;
const int MAXN = 2e5 + 5;
const int INF = 1e18;
int n, a[MAXN];
int press(string p);
char getBeginChar() {
    int ans = press("AB"); if(ans > 0) {
        if(press("A") == 1) return 'A'; return 'B';
    }
    if(press("X") == 1) return 'X'; return 'Y';
}
string guess_sequence(int N) {
    char f = getBeginChar(); if(N == 1) return f; vector<string> againstChar;
    if('A' != f) againstChar.push_back("A");
    if('B' != f) againstChar.push_back("B");
    if('X' != f) againstChar.push_back("X");
    if('Y' != f) againstChar.push_back("Y"); string pre = ""; pre += f;
    int lengthSuffix = N - 1; int M = 0; REP(i, lengthSuffix) {
        string mergeString = pre + f[0] + pre + f[1] + f[0] + pre + f[1] + f[1] +
        pre + f[1] + [2];
        M = (int)pre.size() + 1; int answer = press(mergeString);
        if(answer == M + 1) pre += f[0]; else if(answer == M + 2) pre += f[1]; else {
            pre += f[2];
        } 
    }
    return answer;
}
/*__Im_sogood__{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    solve();
    cerr << "Time elapsed: " << TIME << " s.\n";
    return 0;
}*/

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

combo.cpp:24:17: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
   24 | const int INF = 1e18;
      |                 ^~~~
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:34:48: error: could not convert 'f' from 'char' to 'std::string' {aka 'std::__cxx11::basic_string<char>'}
   34 |     char f = getBeginChar(); if(N == 1) return f; vector<string> againstChar;
      |                                                ^
      |                                                |
      |                                                char
combo.cpp:40:37: error: invalid types 'char[int]' for array subscript
   40 |         string mergeString = pre + f[0] + pre + f[1] + f[0] + pre + f[1] + f[1] +
      |                                     ^
combo.cpp:40:50: error: invalid types 'char[int]' for array subscript
   40 |         string mergeString = pre + f[0] + pre + f[1] + f[0] + pre + f[1] + f[1] +
      |                                                  ^
combo.cpp:40:57: error: invalid types 'char[int]' for array subscript
   40 |         string mergeString = pre + f[0] + pre + f[1] + f[0] + pre + f[1] + f[1] +
      |                                                         ^
combo.cpp:40:70: error: invalid types 'char[int]' for array subscript
   40 |         string mergeString = pre + f[0] + pre + f[1] + f[0] + pre + f[1] + f[1] +
      |                                                                      ^
combo.cpp:40:77: error: invalid types 'char[int]' for array subscript
   40 |         string mergeString = pre + f[0] + pre + f[1] + f[0] + pre + f[1] + f[1] +
      |                                                                             ^
combo.cpp:41:16: error: invalid types 'char[int]' for array subscript
   41 |         pre + f[1] + [2];
      |                ^
combo.cpp:41:23: error: expected identifier before numeric constant
   41 |         pre + f[1] + [2];
      |                       ^
combo.cpp: In lambda function:
combo.cpp:41:25: error: expected '{' before ';' token
   41 |         pre + f[1] + [2];
      |                         ^
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:43:37: error: invalid types 'char[int]' for array subscript
   43 |         if(answer == M + 1) pre += f[0]; else if(answer == M + 2) pre += f[1]; else {
      |                                     ^
combo.cpp:43:75: error: invalid types 'char[int]' for array subscript
   43 |         if(answer == M + 1) pre += f[0]; else if(answer == M + 2) pre += f[1]; else {
      |                                                                           ^
combo.cpp:44:21: error: invalid types 'char[int]' for array subscript
   44 |             pre += f[2];
      |                     ^
combo.cpp:47:12: error: 'answer' was not declared in this scope
   47 |     return answer;
      |            ^~~~~~