Submission #342298

#TimeUsernameProblemLanguageResultExecution timeMemory
342298DrearyJokeCombo (IOI18_combo)C++17
100 / 100
48 ms636 KiB
#include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include "combo.h" using namespace std; using namespace __gnu_pbds; typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<vector<int>> vvi; typedef vector<ll> vll; typedef vector<vector<ll>> vvll; typedef vector<bool> vb; typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set; template <typename T, typename U> std::istream&operator>>(std::istream&i, pair<T,U>&p) {i >> p.x >> p.y; return i;} template<typename T>std::istream&operator>>(std::istream&i,vector<T>&t) {for(auto&v:t){i>>v;}return i;} template <typename T, typename U> std::ostream&operator<<(std::ostream&o, const pair<T,U>&p) {o << p.x << ' ' << p.y; return o;} template<typename T>std::ostream&operator<<(std::ostream&o,const vector<T>&t) {if(t.empty())o<<'\n';for(size_t i=0;i<t.size();++i){o<<t[i]<<" \n"[i == t.size()-1];}return o;} #define deb(x) cout << '>' << #x << ':' << x << endl; #define all(v) v.begin(),v.end() #define rall(v) v.rbegin(),v.rend() #define END '\n' #define inf 9e18 #define ff first #define ss second #define pb push_back string guess_sequence(int n) { string s, p; int a = press("AABB"); char first; if (a) { int ret = press("A"); if (ret) first = 'A'; else first = 'B'; } else { int ret = press("X"); if (ret) first = 'X'; else first = 'Y'; } s += first; if (n == 1) return s; int k = 0; char B[4] = {'A', 'B', 'X', 'Y'}, A[3]; for (int i = 0; i < 4; ++i) { if (B[i] != first) A[k++] = B[i]; } for (int i = 1; i < n - 1; ++i) { p = s + A[0] + s + A[1] + A[0] + s + A[1] + A[1] + s + A[1] + A[2]; int ret = press(p); char nxt; if (ret == i) nxt = A[2]; else if (ret == i + 1) nxt = A[0]; else nxt = A[1]; s += nxt; } a = press(s + 'A' + s + 'B'); if (a == n) { int ret = press(s + 'A'); if (ret == n) first = 'A'; else first = 'B'; } else { int ret = press(s + 'X'); if (ret == n) first = 'X'; else first = 'Y'; } s += first; // cout << s << END; return s; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...