#include #include using namespace std; int ask(std::string S){ std::cout << S << std::endl; int N; std::string T; std::cin >> N >> T; return N; } string find(string prefix, string suffix){ for(int i=0;i<100000;++i){ string s = to_string(i); while(s.size() < 5){ s = '0' + s; } if(ask(prefix + s + suffix) == 5){ return s; } } return "-1"; } int main(){ string notMatchedSuffix; { int matched = 100; for(int i=0;i<10;++i){ string s = string(5, '0' + i); int n = ask(string(5, '0') + s); if(n < matched){ notMatchedSuffix = s; matched = n; } } } string notMatchedPrefix; { int matched = 100; for(int i=0;i<10;++i){ string s = string(5, '0' + i); int n = ask(s + string(5, '0')); if(n < matched){ notMatchedPrefix = s; matched = n; } } } string res = find("", notMatchedSuffix) + find(notMatchedPrefix, ""); std::cout << res << std::endl; }