Submission #566348

#TimeUsernameProblemLanguageResultExecution timeMemory
566348elazarkorenCombo (IOI18_combo)C++17
100 / 100
32 ms592 KiB
#include <bits/stdc++.h> #include "combo.h" #define x first #define y second #define all(v) v.begin(), v.end() #define chkmin(a, b) a = min(a, b) #define chkmax(a, b) a = max(a, b) using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, int> pii; typedef vector<pii> vii; mt19937 rng(time(0)); //char letters[] = {'A', 'B', 'X', 'Y'}; string buttons[] = {"A", "B", "X", "Y"}; string guess_sequence(int n) { string p = ""; if (press("AB") >= 1) { if (press("A") >= 1) p.push_back('A'); else p.push_back('B'); } else { if (press("X") >= 1) p.push_back('X'); else p.push_back('Y'); } if (n == 1) return p; vector<string> letters; for (string s : buttons) { if (s[0] != p[0]) letters.push_back(s); } for (int i = 1; i < n - 1; i++) { shuffle(all(letters), rng); string curr = ""; for (int j = 0; j < 3; j++) { curr += p + letters[0] + letters[j]; } curr += p + letters[1]; int coins = press(curr); if (coins == i + 1) { p += letters[1]; } else if (coins == i) { p += letters[2]; } else { p += letters[0]; } } if (press(p + letters[0] + p + letters[1]) == n) { if (press(p + letters[0]) == n) p += letters[0]; else p += letters[1]; } else { p += letters[2]; } return p; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...