Submission #595291

#TimeUsernameProblemLanguageResultExecution timeMemory
595291Sam_a17Combo (IOI18_combo)C++14
100 / 100
32 ms520 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back #define ld long double #define ll long long #define sz(x) (int((x).size())) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define uniq(x) x.resize(unique(all(x)) - x.begin()); #define lb lower_bound #define ub upper_bound int press(std::string p); std::string guess_sequence(int N) { string pref = ""; int ans = press("AB"), it = 0; if(ans == 2) { pref += "AB", it = 2; } else if(ans == 1) { ans = press("A"); if(ans == 1) { pref += "A"; } else { pref += "B"; } it = 1; } else { ans = press("X"); if(ans == 1) { pref += "X"; } else { pref += "Y"; } it = 1; } if(N == sz(pref)) { return pref; } vector<char> vi; for(auto i: {'X', 'Y', 'A', 'B'}) { if(pref[0] != i) { vi.push_back(i); } } // for(int i = it; i < N - 1; i++) { string harc = pref + vi[0] + pref + vi[1] + vi[0] + pref + vi[1] + vi[1] + pref + vi[1] + vi[2]; ans = press(harc); if(ans == i) { pref += vi[2]; } else if(ans == (i + 1)) { pref += vi[0]; } else if(ans == (i + 2)) { pref += vi[1]; } } // cout << pref << endl; int ans1 = press(pref + vi[0]); if(ans1 == N) { return (pref + vi[0]); } int ans2 = press(pref + vi[1]); if(ans2 == N) { return (pref + vi[1]); } return (pref + vi[2]); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...