제출 #707198

#제출 시각아이디문제언어결과실행 시간메모리
707198baojiaopisu저울 (IOI15_scales)C++14
0 / 100
1 ms312 KiB
#include<bits/stdc++.h> #include "scales.h" using namespace std; using ll = long long; using ld = long double; using ull = unsigned long long; using pii = pair<int, int>; using pll = pair<ll, ll>; using pld = pair<ld, ld>; #define fi first #define se second #define left BAO #define right ANH #define pb push_back #define pf push_front #define mp make_pair #define ins insert #define btpc __builtin_popcount #define btclz __builtin_clz #define sz(x) (int)(x.size()); #define all(x) x.begin(), x.end() #define debug(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] " mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int d4x[4] = {1, 0, -1, 0}; int d4y[4] = {0, 1, 0, -1}; int d8x[8] = {0, 1, 1, 1, 0, -1, -1, -1}; int d8y[8] = {1, 1, 0, -1, -1, -1, 0, 1}; template<class X, class Y> bool minimize(X &x, const Y &y) { if (x > y) { x = y; return true; } return false; } template<class X, class Y> bool maximize(X &x, const Y &y) { if (x < y) { x = y; return true; } return false; } const int MOD = 1e9 + 7; //998244353 template<class X, class Y> void add(X &x, const Y &y) { x = (x + y); if(x >= MOD) x -= MOD; } template<class X, class Y> void sub(X &x, const Y &y) { x = (x - y); if(x < 0) x += MOD; } /* Author : Le Ngoc Bao Anh, 12A5, LQD High School for Gifted Student*/ const ll INF = 1e9; const int N = 1e5 + 10; int ans[N]; void gg(vector<int> a) { int p[6]; for(int i = 0; i < 6; i++) p[i] = a[i]; answer(p); } void orderCoins() { int a = getLightest(1, 2, 3); int b = getMedian(1, 2, 3); int c = 6 - a - b; ans[1] = a; ans[2] = b; ans[3] = c; int p = getNextLightest(4, 5, 6, ans[1]); int f = (p == 4 ? 5 : 4); int curr = getHeaviest(p, f, ans[1]); if(curr == ans[1]) { int r = getMedian(p, f, 15 - p - f); f = 15 - p - r; return gg({p, r, f, ans[1], ans[2], ans[3]}); } if(curr == p) { //f < ans[1] < p int l = 15 - f - p; int x = getMedian(f, l, ans[2]); if(x == f) gg({l, f, ans[1], p, ans[2], ans[3]}); if(x == l) { int t = getMedian(f, l, ans[1]); if(t == l) gg({f, l, ans[1], p, ans[2], ans[3]}); else gg({f, ans[1], p, l, ans[2], ans[3]}); } if(x == ans[2]) { int t = getMedian(ans[2], ans[3], l); if(t == l) gg({f, ans[1], p, ans[2], l, ans[3]}); else gg({f, ans[1], p, ans[2], ans[3], l}); } } //curr == f ans[4] = ans[3]; ans[3] = ans[2]; ans[2] = p; int x = getMedian(ans[3], ans[4], f); if(x == ans[3]) { ans[5] = ans[4]; ans[4] = ans[3]; ans[3] = f; } if(x == f) { ans[5] = ans[4]; ans[4] = f; } if(x == ans[4]) ans[5] = f; int l = 15 - p - f; int r = getMedian(ans[1], ans[3], l); if(r == l) gg({ans[1], ans[2], l, ans[3], ans[4], ans[5]}); if(r == ans[1]) gg({l, ans[1], ans[2], ans[3], ans[4], ans[5]}); if(r == ans[3]) { r = getMedian(ans[4], ans[5], l); if(r == ans[4]) gg({ans[1], ans[2], ans[3], l, ans[4], ans[5]}); if(r == ans[5]) gg({ans[1], ans[2], ans[3], ans[4], ans[5], l}); if(r == l) gg({ans[1], ans[2], ans[3], ans[4], l, ans[5]}); } return gg({0}); } void init(int t) { while(t--) orderCoins(); }
#Verdict Execution timeMemoryGrader output
Fetching results...