#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define REP(i,a,b) for(int i=a;i<(int)b;i++) #define rep(i,n) REP(i,0,n) #define all(c) (c).begin(), (c).end() #define zero(a) memset(a, 0, sizeof a) #define minus(a) memset(a, -1, sizeof a) template inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); } template inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); } typedef long long ll; int const inf = 1<<29; int main() { std::random_device rd; std::mt19937 g(rd()); vector ten(10); iota(all(ten), 0); vector nones; #if 1 #define ASK(A, B, C, D) cout << A << " " << B << " " << C << " " << D << endl; cout << flush; #define QUERY() int hit, blow; cin >> hit >> blow; #else vector ans; std::shuffle(ten.begin(), ten.end(), g); rep(i, 4) ans.push_back(ten[i]); rep(i, 4) cout << ans[i] << " "; cout << endl << endl; vector q(4); #define ASK(A, B, C, D) q[0] = A, q[1] = B, q[2] = C, q[3] = D; printf("%d %d %d %d\n", A, B, C, D); #define QUERY() int hit = 0; rep(i, 4) hit += q[i] == ans[i]; int blow; blow = 0; printf("%d %d\n", hit, blow); #endif while(1) { std::shuffle(ten.begin(), ten.end(), g); ASK(ten[0], ten[1], ten[2], ten[3]) QUERY() if(hit == 4) { exit(0); } if(hit == 0) { rep(i, 4) nones.push_back(ten[i]); break; } } int a = -1; rep(i, 10) { ASK(i, nones[1], nones[2], nones[3]) QUERY() assert(hit != 4); if(hit > 0) { a = i; } } int b = -1; rep(i, 10) { ASK(nones[0], i, nones[2], nones[3]) QUERY() assert(hit != 4); if(hit > 0) { b = i; } } int c = -1; rep(i, 10) { ASK(nones[0], nones[1], i, nones[3]) QUERY() assert(hit != 4); if(hit > 0) { c = i; } } int d = -1; rep(i, 10) { ASK(nones[0], nones[1], nones[2], i) QUERY() assert(hit != 4); if(hit > 0) { d = i; } } ASK(a, b, c, d) QUERY() assert(hit == 4); return 0; }