제출 #277087

#제출 시각아이디문제언어결과실행 시간메모리
277087ASDF123콤보 (IOI18_combo)C++14
100 / 100
40 ms640 KiB
#include "combo.h" #include <bits/stdc++.h> #define fr first #define sc second #define pii pair<int, int> #define szof(s) (int)s.size() #define all(s) s.begin(), s.end() using namespace std; string guess_sequence(int n) { string bad; string s; if (press("AB")) { if (press("A")) { s = "A"; } else { s = "B"; } } else { if (press("X")) { s = "X"; } else { s = "Y"; } } bad = s; if (n == 1) { return s; } for (int i = 1; i <= n - 2; i++) { // we guess i + 1 character int cost; if (bad == "A") { // {B X Y} cost = press(s + "B" + s + "XY" + s + "XX" + s + "XB"); if (cost == szof(s)) { s += 'Y'; } if (cost == szof(s) + 1) { s += 'B'; } if (cost == szof(s) + 2) { s += 'X'; } } if (bad == "B") { // {A X Y} cost = press(s + "A" + s + "XY" + s + "XX" + s + "XA"); if (cost == szof(s)) { s += 'Y'; } if (cost == szof(s) + 1) { s += 'A'; } if (cost == szof(s) + 2) { s += 'X'; } } if (bad == "X") { // { A B Y } cost = press(s + "A" + s + "BA" + s + "BB" + s + "BY"); if (cost == szof(s)) { s += 'Y'; } if (cost == szof(s) + 1) { s += 'A'; } if (cost == szof(s) + 2) { s += 'B'; } } if (bad == "Y") { // { A B X } cost = press(s + "A" + s + "BA" + s + "BB" + s + "BX"); if (cost == szof(s)) { s += 'X'; } if (cost == szof(s) + 1) { s += 'A'; } if (cost == szof(s) + 2) { s += 'B'; } } } // we don't need ask bad char vector <string> good = {}; if (bad != "A") { good.push_back("A"); } if (bad != "B") { good.push_back("B"); } if (bad != "X") { good.push_back("X"); } if (bad != "Y") { good.push_back("Y"); } assert(good.size() == 3); if (press(s + good[0]) == n) { return s + good[0]; } else if (press(s + good[1]) == n) { return s + good[1]; } else { return s + good[2]; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...