Submission #734678

#TimeUsernameProblemLanguageResultExecution timeMemory
734678rainliofficialCombo (IOI18_combo)C++11
0 / 100
0 ms208 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; } template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; } #define sz(x) (int)x.size() #define all(x) begin(x), end(x) /* Date: 2023/05/02 11:56 Problem Link: Topic(s): Reflection: Solution Notes: We can obtain the first character in 2 moves: guess AB if (>=1): then A or B else: then X or Y Then we want to be able to determine 3 characters for every 1 query. Notice we get 4N queries, so it has something to do with 4 possibilities with every query. I initally didn't utilize the 4N constraint, and I thought about queries 2 new characters every time. If we have X, we query XAB: I hoped this would amortize to N queries. However, this would still end up with the issue of having to determine > 2 possibilities with 1 query. Another key constraint is that the first character in S cannot appear again. We can thus use the first character, (e.g. X), to split differrent strings that we want to query. Consider the following method: X___ X___ X___ X___ What can we put in each of the empty spaces to for sure know the next character? XA XBA XBB XBC If A is the next character -> return 1 If B is next char -> return 2 If Y is next character -> 0 */ const int MAXN = 2e5+5, INF = 1e9; int n; vector<char> c = {'A', 'B', 'X', 'Y'}, cc; string guess_sequence(int n){ string s; auto add1 = [&](){ int x = press(s + "AB"); if (x > sz(s)){ // start with A if (press(s + 'A') > sz(s)) s += 'A'; else s += "B"; }else{ if (press(s + 'X') > sz(s)) s += "X"; else s += "Y"; } }; add1(); for (char j : c) if (j != s[0]) cc.push_back(j); for (int i=1; i<n-1; i++){ string q; q += s + cc[0]; for (int j=0; j<3; j++){ q += s + cc[1] + cc[j]; } int x = press(q); if (x == sz(q)) s += cc[2]; else if (x == sz(q) + 1) s += cc[0]; else s += cc[1]; } add1(); return s; } // int main(){ // // cin.tie(0); ios_base::sync_with_stdio(0); // // freopen("file.in", "r", stdin); // // freopen("file.out", "w", stdout); // }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...