Submission #795876

#TimeUsernameProblemLanguageResultExecution timeMemory
795876sadsaCombo (IOI18_combo)C++17
5 / 100
1 ms304 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; using vi = vector<int>; using ii = pair<int, int>; using vii = vector<ii>; using i64 = int64_t; using vl = vector<i64>; using ll = pair<i64, i64>; using vll = vector<ll>; constexpr int iINF = numeric_limits<int>::max(); constexpr i64 lINF = numeric_limits<i64>::max(); #define RANGE(x) begin(x), end(x) template <typename... T> void DBG(T&&... args) { ((cerr << args << ' '), ...) << '\n'; } template <typename T> ostream &operator<<(ostream &out, const vector<T> &vec) { out << '{'; for (size_t i = 0; i < vec.size()-1; ++i) out << vec[i] << ", "; out << vec.back() << '}'; return out; } template <typename T1, typename T2> ostream &operator<<(ostream &out, const pair<T1, T2> &pr) { out << '(' << pr.first << ", " << pr.second << ')'; return out; } std::string guess_sequence(int N) { vector<char> chars{'A', 'B', 'X'}; string p; for (char c : chars) { if (press(string(1, c))) { p = string(1, c); break; } } if (p.empty()) { p = string(1, 'Y'); } else { chars.erase(find(RANGE(chars), p[0])); chars.push_back('Y'); } DBG(p); for (int i = 1; i < N - 1; ++i) { string test = p + chars[0]; for (char c : chars) test += p + chars[1] + c; DBG(p); DBG(test, test.size()); int coins = press(test); if (coins == i) { p += chars[2]; } else if (coins == i+1) { p += chars[0]; } else if (coins == i+2) { p += chars[1]; } else { while (1) new int; } } DBG(p); string test; if (press(test = p + chars[0]) == N) return test; else if (press(test = p + chars[1]) == N) return test; return p + chars[2]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...