Submission #860604

#TimeUsernameProblemLanguageResultExecution timeMemory
860604HakiersCombo (IOI18_combo)C++17
100 / 100
43 ms2044 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; string dictionary[4]; void make_dictionary(string l){ if(l == "A"){ //dictionary = {"A", "B", "X", "Y"}; dictionary[0] = "A"; dictionary[1] = "B"; dictionary[2] = "X"; dictionary[3] = "Y"; } else if(l == "B"){ //dictionary = {"B", "A", "X", "Y"}; dictionary[0] = "B"; dictionary[1] = "A"; dictionary[2] = "X"; dictionary[3] = "Y"; } else if(l == "X"){ //dictionary = {"X", "A", "B", "Y"}; dictionary[0] = "X"; dictionary[1] = "A"; dictionary[2] = "B"; dictionary[3] = "Y"; } else{ //dictionary = {"Y", "A", "B", "X"}; dictionary[0] = "Y"; dictionary[1] = "A"; dictionary[2] = "B"; dictionary[3] = "X"; } } void guess_first(){ int queryAB = press("AB"); if(queryAB == 2) make_dictionary("A"); else if(queryAB == 1){ if(press("A")) make_dictionary("A"); else make_dictionary("B"); } else if(press("X")) make_dictionary("X"); else make_dictionary("Y"); } string make_p(string p, int v, int n){ //#A##### string act = p; act += dictionary[1]; for(int i = v+1; i <= n; i++) act+= dictionary[0]; //#BA#### act += p; act += dictionary[2] + dictionary[1]; for(int i = v+2; i <= n; i++) act+= dictionary[0]; //#BB#### act += p; act += dictionary[2] + dictionary[2]; for(int i = v+2; i <= n; i++) act+= dictionary[0]; //#BX#### act += p; act += dictionary[2] + dictionary[3]; for(int i = v+2; i <= n; i++) act+= dictionary[0]; return act; } string solve(int n){ guess_first(); string act = dictionary[0]; for(int i = 2; i < n; i++){ string p = make_p(act, i, n); int query = press(p); if(query == i) act += dictionary[1]; else if(query == i+1) act += dictionary[2]; else act += dictionary[3]; } //teraz ostatni if(n > 1){ if(press(act + dictionary[1]) == n) act += dictionary[1]; else if(press(act + dictionary[2]) == n) act += dictionary[2]; else act += dictionary[3]; } return act; } string guess_sequence(int N){ return solve(N); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...