Submission #906520

#TimeUsernameProblemLanguageResultExecution timeMemory
906520Andrei_ierdnACombo (IOI18_combo)C++17
100 / 100
13 ms1996 KiB
#include "combo.h" #include <cstring> #include <string> using namespace std; string guess_sequence(int n) { string guess; string available; int rez; // first character rez = press("AB"); if (rez >= 1) { rez = press("A"); if (rez) { guess.push_back('A'); available = "BXY"; } else { guess.push_back('B'); available = "AXY"; } } else { rez = press("X"); if (rez) { guess.push_back('X'); available = "ABY"; } else { guess.push_back('Y'); available = "ABX"; } } if (n == 1) { return guess; } // contained characters for (int i = 2; i < n; i++) { string aux; aux = guess + available[0]; for (int j = 0; j <= 2; j++) { aux = aux + guess + available[1] + available[j]; } rez = press(aux) - i + 1; if (rez == 1) { guess.push_back(available[0]); } else if (rez == 2) { guess.push_back(available[1]); } else { guess.push_back(available[2]); } } // end character rez = press(guess + available[0]); if (rez == n) { return guess + available[0]; } rez = press(guess + available[1]); if (rez == n) { return guess + available[1]; } return guess + available[2]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...