Submission #1280760

#TimeUsernameProblemLanguageResultExecution timeMemory
1280760blackscreen1Combo (IOI18_combo)C++20
100 / 100
8 ms468 KiB
#include "combo.h" #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; typedef tree<long long, null_type, less_equal<long long>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset; #define ll long long #define ld long double #define iloop(m, h) for (ll i = m; i != h; i += (m < h ? 1 : -1)) #define jloop(m, h) for (auto j = m; j != h; j += (m < h ? 1 : -1)) #define kloop(m, h) for (auto k = m; k != h; k += (m < h ? 1 : -1)) #define lloop(m, h) for (auto l = m; l != h; l += (m < h ? 1 : -1)) #define iloop_(m, h, g) for (auto i = m; i != h; i += g) #define jloop_(m, h, g) for (auto j = m; j != h; j += g) #define kloop_(m, h, g) for (auto k = m; k != h; k += g) #define lloop_(m, h, g) for (auto l = m; l != h; l += g) #define getchar_unlocked _getchar_nolock // comment before submission #define pll pair<ll, ll> #define plll pair<ll, pll> #define pllll pair<pll, pll> #define vll vector<ll> #define qll queue<ll> #define dll deque<ll> #define pqll priority_queue<ll> #define gll greater<ll> #define INF 1000000000000000 #define MOD1 1000000007 #define MOD2 998244353 #define MOD3 1000000009 mt19937 rng(chrono::system_clock::now().time_since_epoch().count()); string guess_sequence(int N) { int ab = press("AB"), a, x; string fc, clt; if (ab >= 1) { a = press("A"); if (a == 1) fc = "A", clt = "BXY"; else fc = "B", clt = "AXY"; } else { x = press("X"); if (x == 1) fc = "X", clt = "ABY"; else fc = "Y", clt = "ABX"; } if (N == 1) return fc; int cptr = 1; int isf; while (cptr < N-1) { isf = press(fc + clt[0] + clt[0] + fc + clt[0] + clt[1] + fc + clt[1] + clt[0]); if (isf == cptr) { fc += clt[2]; cptr++; continue; } if (isf == cptr+1) { isf = press(fc + clt[1] + clt[1]); if (isf == cptr) { fc += clt[0]; fc += clt[2]; } else if (isf == cptr + 1) { fc += clt[1]; fc += clt[2]; } else {fc += clt[1]; fc += clt[1];} } else if (isf == cptr+2) { isf = press(fc + clt[0] + clt[0]); if (isf == cptr) { fc += clt[1]; fc += clt[0]; } else if (isf == cptr + 1) { fc += clt[0]; fc += clt[1]; } else {fc += clt[0]; fc += clt[0];} } cptr += 2; //cout << fc << "," << cptr << "\n"; } //cout << fc << " " << cptr << "g\n"; if (cptr == N) return fc; ab = press(fc + "A" + fc + "B"); if (ab == cptr) { x = press(fc + "X"); if (x == cptr) return fc + "Y"; else return fc + "X"; } a = press(fc + "A"); if (a == cptr) return fc + "B"; return fc + "A"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...