Submission #393723

#TimeUsernameProblemLanguageResultExecution timeMemory
393723ruadhanCombo (IOI18_combo)C++14
5 / 100
1 ms256 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; #define sz(x) (int)x.size() // string S; // int N; // int press(string p) // { // // cout << "pressing " << p << '\n'; // if ((int)p.length() > N * 4) // return -1; // int ret = 0; // int counter = 0; // int i = 0; // int j = 0; // while (i < (int)p.size()) // { // // cout << "i = " << i << '\n'; // while (i < (int)p.size() && j < (int)S.size() && p.at(i) == S.at(j)) // { // i++, j++, counter++; // } // ret = max(ret, counter); // j = 0, i++; // counter = 0; // } // return ret; // } string guess_sequence(int N) { vector<char> chars = {'A', 'B', 'X', 'Y'}; string s = ""; array<char, 3> otherChars; if (press("AB")) { if (press("A")) { s += "A"; otherChars = {'B', 'X', 'Y'}; } else { s += "B"; otherChars = {'A', 'X', 'Y'}; } } else { if (press("X")) { s += "X"; otherChars = {'A', 'B', 'Y'}; } else { s += "Y"; otherChars = {'A', 'B', 'X'}; } } for (int i = 1; i < N - 1; i++) { string combo = s + otherChars[0] + s + otherChars[1] + otherChars[0] + s + otherChars[1] + otherChars[1] + s + otherChars[1] + otherChars[2]; int start = sz(s); int ret = press(combo); if (start + 2 == ret) s += otherChars[1]; else if (start + 1 == ret) s += otherChars[0]; else s += otherChars[2]; } if (press(s + "A" + s + "B") > sz(s)) { if (press(s + "A") > sz(s)) { s += "A"; } else { s += "B"; } } else { if (press(s + "X") > sz(s)) { s += "X"; } else { s += "Y"; } } return s; } // int main() // { // S = "ABXYY"; // N = S.length(); // cout << guess_sequence(N) << '\n'; // return 0; // }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...