Submission #172048

#TimeUsernameProblemLanguageResultExecution timeMemory
172048nobikCombo (IOI18_combo)C++14
100 / 100
72 ms680 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; string guess_sequence(int n) { string chars[] = {"A", "B", "X", "Y"}; int first = 0; if (press("AB") > 0) { first = press("B"); } else { first = 2 + press("Y"); } string r = chars[first]; if (n == 1) return r; vector<int> ids; for (int j = 0; j < 4; ++j) { if (j == first) continue; ids.push_back(j); } for (int i = 0; i < n - 2; ++i) { string f = r + chars[ids[0]]; string s = r + chars[ids[1]]; string query = (f + chars[ids[0]]) + (f + chars[ids[1]]) + (f + chars[ids[2]]) + s; int c = press(query); if (c == (int) f.size() + 1) r += chars[ids[0]]; else if (c == (int) s.size()) r += chars[ids[1]]; else r += chars[ids[2]]; } if (press(r + chars[ids[0]]) == n) r += chars[ids[0]]; else if (press(r + chars[ids[1]]) == n) r += chars[ids[1]]; else r += chars[ids[2]]; return r; } /* Usage: std::string p = ""; for (int i = 0; i < 4 * N; ++i) { p += 'A'; } int coins = press(p); std::string S = ""; for (int i = 0; i < N; ++i) { S += 'A'; } return S; */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...