Submission #484732

#TimeUsernameProblemLanguageResultExecution timeMemory
484732dynam1cCombo (IOI18_combo)C++17
100 / 100
41 ms644 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; #define all(x) x.begin(),x.end() #define endl "\n" string guess_sequence(int n) { string ans; ans.assign(n, 0); char f; if (press("AB")) if (press("A")) f = 'A'; else f = 'B'; else if (press("X")) f = 'X'; else f = 'Y'; vector<char> r; for (char c : "ABXY") if (c and c != f) r.push_back(c); ans[0] = f; if (n == 1) return ans; for (int i = 1; i < n-1; i++) { string q; for (char c : r) q.insert(q.end(), ans.begin(), ans.begin()+i), q.push_back(r[2]), q.push_back(c); q.insert(q.end(), ans.begin(), ans.begin()+i), q.push_back(r[1]); /*for (char c : q) cout << (int) c << " "; cout << endl;*/ ans[i] = r[press(q)-i]; } ans.pop_back(); if (press(ans + "A" + ans + "B") == n) if (press(ans + "A") == n) f = 'A'; else f = 'B'; else if (press(ans + "X") == n) f = 'X'; else f = 'Y'; ans.push_back(f); return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...