#include using namespace std; bool check(string s) { sort(s.begin(), s.end()); for (int i = 1; i < s.size(); i++) { if (s[i - 1] == s[i]) { return false; } } return true; } int main() { std::random_device seed_gen; std::uint32_t seed = seed_gen(); std::default_random_engine engine(seed); vector s; for (int i = 0; i <= 99999; i++) { int v = i; string cur; for (int j = 0; j < 5; j++) { cur.push_back('0' + v % 10); v /= 10; } reverse(cur.begin(), cur.end()); if (check(cur)) { s.push_back(cur); } } int t = 0; while (s.size()) { std::uniform_int_distribution<> dist(0, s.size() - 1); string nx = s[dist(engine)]; cout << nx << "\n"; fflush(stdout); vector> hb(30); for (auto &nx : hb) { cin >> nx.first >> nx.second; } if (hb[0].first == 5) { return 0; } hb.resize(30 - t); if (hb.back().first == 5) { t++; hb.resize(30 - t); } vector ns; for (string x : s) { pair p = {0, 0}; for (char c : x) { if (nx.find(c) < 5) { p.second; } } for (int i : std::ranges::iota_view(0, 5)) { if (nx[i] == x[i]) { p.first++; p.second--; } } for (auto q : hb) { if (q == p) { ns.push_back(x); break; } } } s.swap(ns); } }