제출 #1148871

#제출 시각아이디문제언어결과실행 시간메모리
1148871andrejikusCombo (IOI18_combo)C++20
컴파일 에러
0 ms0 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; void DBG() { cerr << "]" << endl; } template<class H, class... T> void DBG(H h, T... t) { cerr << to_string(h); if(sizeof...(t)) cerr << ", "; DBG(t...); } #define dbg(...) cerr << "[" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__) const int N = 2e5 + 3; string ELEM[4] = {"A", "B", "X", "Y"}; string guess_sequence(int n) { string s = ""; string p = ELEM[0] + ELEM[1]; if (press(p) > 0) { string c = ELEM[0]; if (press(c)) s += ELEM[0]; else s += ELEM[1]; } else { string c = ELEM[2]; if (press(c)) s += ELEM[2]; else s += ELEM[3]; } /// 3 qry for (int i = 2; i <= n; i++) { vector<string> vec; for (int d = 0; d < 4; d++) if (s[0] != char(ELEM[d])) vec.push_back(ELEM[d]); string p = s + vec[0] + s + vec[1]; if (press(p) == i) { string c = s + vec[0]; if (press(c) == i) s += vec[0]; else s += vec[1]; } else { s += vec[2]; } } return s; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:34:25: error: invalid cast from type 'std::string' {aka 'std::__cxx11::basic_string<char>'} to type 'char'
   34 |             if (s[0] != char(ELEM[d]))
      |                         ^~~~~~~~~~~~~