Submission #937733

#TimeUsernameProblemLanguageResultExecution timeMemory
937733AlcabelCombo (IOI18_combo)C++17
5 / 100
1 ms344 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; string guess_sequence(int N) { string s = "", p = "", lets = "ABXY"; p += lets[0]; p += lets[1]; // cerr << "p: " << p << '\n'; if (press(p)) { p = lets[0]; // cerr << "p: " << p << '\n'; if (press(p)) { s += lets[0]; } else { s += lets[1]; } } else { p = lets[2]; // cerr << "p: " << p << '\n'; if (press(p)) { s += lets[2]; } else { s += lets[3]; } } // cerr << "first: " << s << '\n'; for (int i = 0; i < 4; ++i) { if (lets[i] == s[0]) { swap(lets[i], lets.back()); lets.pop_back(); break; } } for (int i = 0; i < N - 2; ++i) { p = s + lets[0]; p += s + lets[1] + lets[0]; p += s + lets[1] + lets[1]; p += s + lets[1] + lets[2]; // cerr << "i: " << i << ", p: " << p << '\n'; int len = press(p); // cerr << "len: " << len << '\n'; if (len == (int)s.size() + 1) { s += lets[0]; } else if (len == (int)s.size() + 2) { s += lets[1]; } else { s += lets[2]; } } // cerr << "last: " << s << '\n'; // cerr << "p: " << s + lets[0] + s + lets[1] << '\n'; if (press(s + lets[0] + s + lets[1]) == N) { if (press(s + lets[0]) == N) { s += lets[0]; } else { s += lets[1]; } } else { s += lets[2]; } return s; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...