제출 #102843

#제출 시각아이디문제언어결과실행 시간메모리
102843wxh010910콤보 (IOI18_combo)C++17
100 / 100
58 ms660 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; string guess_sequence(int n) { string alphabet = "ABXY", answer = ""; int first_letter = press("AB"); if (first_letter) { if (press("A")) { first_letter = 0; answer = "A"; } else { first_letter = 1; answer = "B"; } } else { if (press("X")) { first_letter = 2; answer = "X"; } else { first_letter = 3; answer = "Y"; } } if (n == 1) { return answer; } for (int i = 0; i < n - 2; ++i) { int current = 0; string query = ""; for (int j = 0; j < 4; ++j) { if (j != first_letter) { if (current == 1) { query += answer + alphabet[j]; } else if (current == 2) { for (int k = 0; k < 4; ++k) { if (k != first_letter) { query += answer + alphabet[j] + alphabet[k]; } } } ++current; } } int result = press(query); current = answer.length(); for (int j = 0; j < 4; ++j) { if (j != first_letter) { if (result == current) { answer += alphabet[j]; } ++current; } } } if (press(answer + "A" + answer + "B") == n) { if (press(answer + "A") == n) { return answer + "A"; } else { return answer + "B"; } } else { if (press(answer + "X") == n) { return answer + "X"; } else { return answer + "Y"; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...