Submission #416447

#TimeUsernameProblemLanguageResultExecution timeMemory
416447vishesh312Combo (IOI18_combo)C++17
100 / 100
33 ms568 KiB
#include "combo.h" #include "bits/stdc++.h" using namespace std; /* #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>; */ #define all(x) begin(x), end(x) #define sz(x) (int)x.size() using ll = long long; const int mod = 1e9+7; /* string S = "ABXYY"; int press(string s) { int mx = 0; for (int i = 0; i < sz(s); ++i) { if (s[i] == S[0]) { int j = i+1; for (; s[j] == S[j-i] and j-i < sz(S) and j < sz(s); ++j){} mx = max(mx, j-i); } } return mx; } */ string guess_sequence(int n) { string ans = "", a = "A", b = "B", c = "X", d = "Y"; if (press("AB")) { if (press("A")) { ans += "A"; a = d; } else { ans += "B"; b = d; } } else { if (press("X")) { ans += "X"; c = d; } else { ans += "Y"; } } while (sz(ans) < n-1) { int x = press(ans + a + a + ans + a + b + ans + b + a) - sz(ans); if (x == 2) { x = press(ans + a + a) - sz(ans); if (x == 2) { ans += a + a; } else if (x == 1) { ans += a + b; } else { ans += b + a; } } else if (x == 1) { x = press(ans + b + b) - sz(ans); if (x == 2) { ans += b + b; } else if (x == 1) { ans += b + c; } else { ans += a + c; } } else { ans += c; } } if (sz(ans) != n) { int x = press(ans + a + ans + b) - sz(ans); if (x == 1) { x = press(ans + a) - sz(ans); if (x == 1) { ans += a; } else { ans += b; } } else { ans += c; } } return ans; } /* signed main() { cout << guess_sequence(5) << '\n'; } */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...