Submission #1215890

#TimeUsernameProblemLanguageResultExecution timeMemory
1215890iulia_morariuCombo (IOI18_combo)C++20
100 / 100
8 ms548 KiB
#include <algorithm> #include <iostream> #include <fstream> #include <climits> #include <vector> #include <stack> #include <cmath> #include "combo.h" // #include <bits/stdc++.h> #define in cin #define out cout using namespace std; // string ce_vreau; // int N; // void wrong_answer(const char *MSG) { // printf("Wrong Answer: %s\n", MSG); // exit(0); // } // int press(std::string p) { // int len = p.length(); // if (len > 4 * N) { // cerr << "len = " << len << " 4 * N = " << 4 * N << '\n'; // wrong_answer("invalid press1"); // } // for (int i = 0; i < len; ++i) { // if (p[i] != 'A' && p[i] != 'B' && p[i] != 'X' && p[i] != 'Y') { // wrong_answer("invalid press2"); // } // } // int coins = 0; // for (int i = 0, j = 0; i < len; ++i) { // if (j < N && ce_vreau[j] == p[i]) { // ++j; // } else if (ce_vreau[0] == p[i]) { // j = 1; // } else { // j = 0; // } // coins = max(coins, j); // } // return coins; // } string guess_sequence(int n){ string s; // ce am deja // first string q = "AB"; int x = press(q); if(x == 0){ x = press("X"); if(x == 1) s.push_back('X'); else s.push_back('Y'); }else{ x = press("A"); if(x == 1) s.push_back('A'); else s.push_back('B'); } if(n == 1) return s; vector<string> pos; if(s[0] != 'A') pos.push_back("A"); if(s[0] != 'B') pos.push_back("B"); if(s[0] != 'X') pos.push_back("X"); if(s[0] != 'Y') pos.push_back("Y"); while(s.size() < n - 1){ q = s + pos[0] + pos[0] + s + pos[0] + pos[1] + s + pos[0] + pos[2] + s + pos[1]; // cerr << "INTREB PE " << q << '\n'; int x = press(q); if(x == s.size()){ s += pos[2]; }else if(x == s.size() + 1){ s += pos[1]; }else s += pos[0]; } x = press(s + pos[0] + s + pos[1]); if(x == s.size() + 1){ x = press(s + pos[0]); if(x == n) s += pos[0]; else s += pos[1]; }else s += pos[2]; return s; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...