#include #include #include using namespace std; void send(int *n, int &x, int &y) { printf("%d %d %d %d\n", n[0], n[1], n[2], n[3]); fflush(stdout); char buff[1024]; fgets(buff, 1024, stdin); sscanf(buff, "%d %d", &x, &y); } int main(int argc, char *argv[]) { int n[4] = {}, x = -1, y = -1; while (!(x == 0 && y == 0)) { for (int i = 0; i < 4; ++i) { n[i] = -1; while (n[i] < 0) { n[i] = (rand() * 10) / (RAND_MAX + 1); for (int j = 0; j < i; ++j) { if (n[j] == n[i]) { n[i] = -1; break; } } } } send(n, x, y); if (x == 4) { return 0; } } for (int i = 0; i < 4; ++i) { x = -1; while (x != (i + 1)) { n[i] = (n[i] + 1) % 10; send(n, x, y); } } return 0; }