Submission #778447

#TimeUsernameProblemLanguageResultExecution timeMemory
778447Durza42Combo (IOI18_combo)C++14
5 / 100
1 ms256 KiB
#include <iostream> #include <vector> #include <array> #include <string> #include "combo.h" #define endl '\n' #define ll long long int using namespace std; #define SOLUCE #ifdef BRUTFORCE string guess_sequence(int N) { vector<char> LETTERS = { 'A', 'B', 'X', 'Y' }; string S = "."; for(auto&& l : LETTERS) { S[0] = l; if(press(S) > 0) break; } for(int i = 1 ; i < N ; ++i) { S += "."; for(auto&& l : LETTERS) { if(l == S[0]) continue; S[i] = l; if(press(S) == i + 1) break; } } return S; } #endif /**************************/ #ifdef BRUTFORCE2 string guess_sequence(int N) { vector<char> LETTERS = { 'A', 'B', 'X', 'Y' }; string S = "."; for(auto&& l : LETTERS) { S[0] = l; if(press(S) > 0) break; } for(int i = 1 ; i < N ; ++i) { int nb_seen = 0; S += "."; for(int j = 0 ; j < int(LETTERS.size()) ; ++j) { if(LETTERS[j] == S[0]) continue; if(nb_seen == 2) { if(LETTERS[j] == S[0]) ++i; S[i] = LETTERS[j]; break; } S[i] = LETTERS[j]; if(press(S) == i + 1) break; nb_seen++; } } return S; } #endif #ifdef SOLUCE constexpr array<char, 4> LETTERS { 'A', 'B', 'X', 'Y' }; string guess_sequence(int N) { string S = "."; if(press("AB") > 0) { if(press("A") > 0) S[0] = 'A'; else S[0] = 'B'; } else { if(press("X") > 0) S[0] = 'X'; else S[0] = 'Y'; } vector<string> l; for(int i = 0 ; i < int(LETTERS.size()) ; ++i) { if(LETTERS[i] == S[0]) continue; l.push_back("."); l.back() = LETTERS[i]; } for(int i = 1 ; i < N - 1 ; ++i) { string request = S + l[0] + l[0] + S + l[0] + l[1] + S + l[0] + l[2] + S + l[1]; int p = press( request ); if(p == int(S.length()) + 0) S += l[2]; if(p == int(S.length()) + 1) S += l[1]; if(p == int(S.length()) + 2) S += l[0]; } /* TODO last char */ if(press(S + l[0]) > int(S.length())) S += l[0]; else { if(press(S + l[1]) > int(S.length())) S += l[1]; else S += l[2]; } return S; } #endif
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...