#define _CRT_SECURE_NO_WARNINGS #define _USE_MATH_DEFINES #include "bits/stdc++.h" #define REP(i,a,b) for(i=a;i> pre_x >> pre_y; rep(i, 10) status[i] = 0; while (status.size() > 4) { int target = -1; int try_num; srand(time(NULL)); vector target_vec; for (auto v : pre_query) { target_vec.push_back(v); } target = target_vec[rand() % target_vec.size()]; set now_query = pre_query; now_query.erase(target); vector o; for (auto a : status) { if (now_query.count(a.first) == 0) { o.push_back(a.first); } } try_num = o[rand() % o.size()]; now_query.insert(try_num); // random大丈夫? auto itr = now_query.begin(); for (i = 0; i<3; i++, itr++) cout << *itr << " "; cout << *itr << endl; cin >> now_x >> now_y; int diff = now_x + now_y - (pre_x + pre_y); if (diff < 0) { status.erase(try_num); status[target] = 1; } if (diff > 0) { status.erase(target); status[try_num] = 1; } pre_query = now_query; pre_x = now_x; pre_y = now_y; for (auto v : status) { fprintf(stderr,"status[%d] = %d\n", v.first, v.second); } } vector query; for (auto a : status) query.push_back(a.first); do { rep(i, 3) cout << query[i] << " "; cout << query[i] << endl; cin >> now_x >> now_y; if (now_x == 4) break; } while (next_permutation(ALL(query))); }