제출 #1128560

#제출 시각아이디문제언어결과실행 시간메모리
1128560mbalsells콤보 (IOI18_combo)C++20
0 / 100
0 ms396 KiB
#include "combo.h" using namespace std; // ABXY string buttons = "ABXY"; int get_index(string& s){ for (int i = 0; i < 4; ++i){ if (s[i] == buttons[i]) return i; } } char get_first(){ if (press("AB") == 1){ if (press("A")) return 'A'; else return 'B'; } else { if (press("X") == 1) return 'X'; else return 'Y'; } } char get_next(string s){ int index = get_index(s); string left_buttons; for (int i = 1; i <= 3; ++i){ left_buttons.push_back(buttons[(index + i) % 4]); } int l = s.size(); string query = s; query.push_back(left_buttons[0]); for (int i = 0; i < 3; ++i){ query += s; query.push_back(left_buttons[1]); query.push_back(left_buttons[i]); } int response = press(query); if (response == l) return left_buttons[2]; if (response == l + 1) return left_buttons[0]; return left_buttons[1]; } char get_last(string& s){ int index = get_index(s); string left_buttons; for (int i = 1; i <= 3; ++i){ left_buttons.push_back(buttons[(index + i) % 4]); } int l = s.size(); string query = s; query.push_back(left_buttons[0]); if (press(query) == l + 1) return left_buttons[0]; query = s; query.push_back(left_buttons[1]); if (press(query) == l + 1) return left_buttons[1]; return left_buttons[2]; } std::string guess_sequence(int N) { string ans; ans.push_back(get_first()); if (N == 1) return ans; for (int i = 2; i < N; ++i){ ans.push_back(get_next(ans)); } ans.push_back(get_last(ans)); return ans; }

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

combo.cpp: In function 'int get_index(std::string&)':
combo.cpp:12:1: warning: control reaches end of non-void function [-Wreturn-type]
   12 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...