#include using namespace std; using namespace chrono; #if __has_include() #include using namespace atcoder; #endif int main() { random_device rnd; mt19937 engine(rnd()); uniform_int_distribution<> rand10(0, 9); vector> qss; vector> rs; for (int64_t i = 0; i < 99; i++) { vector qs(4); qs[0] = rand10(engine); do { qs[1] = rand10(engine); } while (qs[1] == qs[0]); do { qs[2] = rand10(engine); } while (qs[2] == qs[0] || qs[2] == qs[1]); do { qs[3] = rand10(engine); } while (qs[3] == qs[0] || qs[3] == qs[1] || qs[3] == qs[2]); qss.push_back(qs); for (auto &&q : qs) { cout << q << ' '; } cout << endl; int64_t x, y; cin >> x >> y; rs.push_back({x, y}); if (x == 4 && y == 0) { return 0; } } auto f = [](vector qs, vector ns) { pair ret(0, 0); for (int64_t i = 0; i < qs.size(); i++) { if (qs[i] == ns[i]) { ret.first++; } for (int64_t j = 0; j < qs.size(); j++) { if (i == j) { continue; } if (qs[i] == ns[j]) { ret.second++; } } } return ret; }; for (int64_t a = 0; a <= 9; a++) { for (int64_t b = 0; b <= 9; b++) { for (int64_t c = 0; c <= 9; c++) { for (int64_t d = 0; d <= 9; d++) { vector ns({a, b, c, d}); bool flag = true; for (int64_t i = 0; i < qss.size(); i++) { flag &= f(qss[i], ns) == rs[i]; } if (flag) { cout << a << ' ' << b << ' ' << c << ' ' << d << endl; return 0; } } } } } return 0; }