#include #include #include using namespace std; pair judge(const string& ans, const string& challenge){ int h = 0, b = 0; for(int i=0;i<4;i++){ if(challenge[i] == ans[i]){ ++h; } else if(ans.find(challenge[i]) != string::npos){ ++b; } } return make_pair(h, b); } pair ask(const string& S){ cout << S[0] << " " << S[1] << " " << S[2] << " " << S[3] << endl; int h, b; cin >> h >> b; return make_pair(h, b); } const pair last = make_pair(4, 0); int main(){ srand(1); vector cand; for(char a='0';a<='9';a++){ for(char b='0';b<='9';b++)if(b != a){ for(char c='0';c<='9';c++)if(c != a && c != b){ for(char d='0';d<='9';d++)if(d != a && d != b && d != c){ string num = ""; num += a; num += b; num += c; num += d; cand.push_back(num); } } } } int size = cand.size(); for(;;){ int r = rand() % size; string challenge = cand[r]; auto res = ask(challenge); if(res == last){ break; } int j = 0; for(int i=0;i