#define _USE_MATH_DEFINES #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; unsigned xor128(){ static unsigned x=123456789,y=362436069,z=521288629,w=88675123; unsigned t; t=(x^(x<<11));x=y;y=z;z=w; return( w=(w^(w>>19))^(t^(t>>8)) ); } pair query(const vector& v){ cout << v[0]; for(unsigned i=1; i p; cin >> p.first >> p.second; return p; } int main() { vector v; set > s; for(;;){ vector w; while(w.size() != 4){ int a = xor128() % 10; if(find(w.begin(), w.end(), a) == w.end()) w.push_back(a); } if(s.find(w) == s.end()){ s.insert(w); pair p = query(w); if(p.first == 4) return 0; if(p.first + p.second == 0){ v.swap(w); break; } } } for(int i=0; i<4; ++i){ for(int a=0; ; ++a){ if(find(v.begin(), v.end(), a) != v.end()) continue; vector w = v; w[i] = a; pair p = query(w); if(p.first == i + 1){ v.swap(w); break; } } } }