제출 #587977

#제출 시각아이디문제언어결과실행 시간메모리
587977vilji콤보 (IOI18_combo)C++17
97 / 100
33 ms528 KiB
#include <bits/stdc++.h> #define rep(i, a, b) for (int i = (a); i < (b); i++) using namespace std; #define pb push_back #include "combo.h" string guess_sequence(int N) { vector<char> btns = {'A', 'B', 'X', 'Y'}; char fst; rep(i, 0, btns.size()) { int c = btns[i]; if (i == 3) { fst = c; break; } string p = ""; p += c; int coins = press(p); if (coins != 0) { fst = c; break; } } vector<char> oth; if (N == 1) { string res = ""; res += fst; return res; } for (char c : btns) { if (c != fst) oth.pb(c); } string ans = ""; ans += fst; rep(i, 1, N - 1) { string p = ""; p += ans; p += oth[0]; p += oth[0]; p += ans; p += oth[0]; p += oth[1]; p += ans; p += oth[0]; p += oth[2]; p += ans; p += oth[1]; int coins = press(p); if (coins == i) ans += oth[2]; else if (coins == i + 1) ans += oth[1]; else if (coins == i + 2) ans += oth[0]; else assert(false); } for (int i = 0; i < 3; i++) { char c = oth[i]; if (i == 2) { string p = ans; p += c; return p; } string p = ans; p += c; int coins = press(p); if (coins == N) { return p; } } assert(false); return ""; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:3:42: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    3 | #define rep(i, a, b) for (int i = (a); i < (b); i++)
      |                                          ^
combo.cpp:14:3: note: in expansion of macro 'rep'
   14 |   rep(i, 0, btns.size()) {
      |   ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...