제출 #158457

#제출 시각아이디문제언어결과실행 시간메모리
158457davitmarg저울 (IOI15_scales)C++17
45.45 / 100
2 ms376 KiB
/*DavitMarg*/ #include <iostream> #include <algorithm> #include <cmath> #include <vector> #include <string> #include <cstring> #include <map> #include <set> #include <queue> #include <iomanip> #include <bitset> #include <stack> #include <cassert> #include <iterator> #include <fstream> #define mod 1000000000ll #define LL long long #define LD long double #define MP make_pair #define PB push_back #define all(v) v.begin(), v.end() using namespace std; #ifndef death #include "scales.h" #endif #ifdef death int getHeaviest(int a, int b, int c) { cout << "? Heavy" << a << " " << b << " " << c << endl; int res; cin >> res; return res; } int getMedian(int a, int b, int c) { cout << "? Median" << a << " " << b << " " << c << endl; int res; cin >> res; return res; } int getLightest(int a, int b, int c) { cout << "? Light" << a << " " << b << " " << c << endl; int res; cin >> res; return res; } int getNextLightest(int a, int b, int c, int d) { cout << "? " << a << " " << b << " " << c << " " << d << endl; int res; cin >> res; return res; } void answer(int *a) { cout << "! "; for (int i = 0; i < 6; i++) cout << a[i] << " "; cout << endl; } #endif int n = 6; void init(int T) { srand(644645 + T); } void orderCoins() { vector<int> ind, l, r, ans; for (int i = 1; i <= n; i++) ind.PB(i); random_shuffle(all(ind)); l.PB(getLightest(ind[0], ind[1], ind[2])); l.PB(getMedian(ind[0], ind[1], ind[2])); for (int i = 0; i < 3; i++) if (ind[i] != l[0] && ind[i] != l[1]) l.PB(ind[i]); r.PB(getLightest(ind[3], ind[4], ind[5])); r.PB(getMedian(ind[3], ind[4], ind[5])); for (int i = 3; i < n; i++) if (ind[i] != r[0] && ind[i] != r[1]) r.PB(ind[i]); reverse(all(l)); reverse(all(r)); ans.PB(getLightest(r.back(), l.back(), r[r.size() - 2])); if (ans.back() == r.back()) r.pop_back(); else l.pop_back(); while (!l.empty() || !r.empty()) { if (l.empty()) { ans.PB(r.back()); r.pop_back(); } else if (r.empty()) { ans.PB(l.back()); l.pop_back(); } else { ans.PB(getMedian(r.back(), l.back(), ans[0])); if (ans.back() == r.back()) r.pop_back(); else l.pop_back(); } } int ANS[6]; for (int i = 0; i < n; i++) ANS[i] = ans[i]; answer(ANS); } #ifdef death int main() { int T; cin >> T; init(T); while (T--) { orderCoins(); } return 0; } #endif /* 2 2 8 1 7 */
#Verdict Execution timeMemoryGrader output
Fetching results...