Submission #352160

#TimeUsernameProblemLanguageResultExecution timeMemory
352160SprdaloCombo (IOI18_combo)C++17
100 / 100
60 ms600 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> pi; typedef pair<ll, ll> pl; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<double> vd; typedef vector<bool> vb; typedef vector<char> vc; typedef vector<string> vs; typedef vector<pi> vp; typedef vector<pl> vpl; string pass; int N, cnt; int pres(string s){ ++cnt; int n = N, m = s.length(); if (m > 4*n || m<0) throw SIGSEGV; int sol = 0; for (int i = 0; i < m; ++i){ int r = 0, ind = i; for (int j = 0; j < n; ++j){ if (s[ind] == pass[j]){ ++r; ++ind; } else { sol = max(sol, r); break; } } sol = max(sol, r); } return sol; } string guess_sequence(int n){ int k = press("AB"); char d; if (!k){ k = press("X"); if (!k) d = 'Y'; else d = 'X'; } else { k = press("A"); if (!k) d = 'B'; else d = 'A'; } string st = "ABXY"; if (d == 'A') st = "BXY"; else if (d == 'B') st = "AXY"; else if (d == 'X') st = "ABY"; else st = "ABX"; char a = st[0], b = st[1], c = st[2]; string s = ""; s += d; if (n == 1) return s; for (int i = 2; i < n; ++i){ string t = ""; t += (s + a + a); t += (s + a + b); t += (s + a + c); t += (s + b); // cout << s << ' '; // cout << "PITAM " << t << ' '; k = press(t); //cout << k << '\n'; if (k == i-1){ s += c; continue; } if (k == i){ s += b; continue; } s += a; } // cout << s << '\n'; k = press(s+a); if (k == n){ s += a; return s; } k = press(s+b); if (k == n){ s += b; return s; } s += c; return s; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...