#include #include using namespace std; list pt; void est(const int o[], const int n[], int& x, int& y) { x = y = 0; for ( int i = 0; i < 4; i++ ) { if ( o[i] == n[i] ) { x++; } else { for ( int j = 0; j < 4; j++ ) { if ( o[i] == n[j] ) { y++; break; } } } } } void io(int n[], int& x, int& y) { cout << n[0] << " " << n[1] << " " << n[2] << " " << n[3] << endl; cin >> x >> y; } int main() { for ( int i = 0; i < 10; i++ ) { for ( int j = 0; j < 10; j++ ) { if ( i == j ) continue; for ( int k = 0; k < 10; k++ ) { if ( i == k || j == k ) continue; for ( int l = 0; l < 10; l++ ) { if ( i == l || j == l || k == l ) continue; int* n = new int[4] { i, j, k, l }; pt.push_back(n); } } } } for ( ;; ) { int x, y; auto it = pt.begin(); int n[] = { (*it)[0], (*it)[1], (*it)[2], (*it)[3] }; io(n, x, y); if ( x == 4 ) { break; } do { int xt, yt; int o[] = { (*it)[0], (*it)[1], (*it)[2], (*it)[3] }; est(*it, n, xt, yt); auto t_it = it++; if ( x != xt || y != yt ) { pt.erase(t_it); } else { int a = 0; } } while ( it != pt.end() ); } return 0; }