Submission #482756

#TimeUsernameProblemLanguageResultExecution timeMemory
482756dxz05Scales (IOI15_scales)C++14
45.45 / 100
1 ms204 KiB
#include "scales.h" #include <bits/stdc++.h> using namespace std; void init(int T) { /* ... */ } map<vector<int>, int> mem[4]; int Lightest(int A, int B, int C){ if (mem[0].find({A, B, C}) != mem[0].end()) return mem[0][{A, B, C}]; return mem[0][{A, B, C}] = getLightest(A, B, C); } int Median(int A, int B, int C){ if (mem[1].find({A, B, C}) != mem[1].end()) return mem[1][{A, B, C}]; return mem[1][{A, B, C}] = getMedian(A, B, C); } int Heaviest(int A, int B, int C){ if (mem[2].find({A, B, C}) != mem[2].end()) return mem[2][{A, B, C}]; return mem[2][{A, B, C}] = getHeaviest(A, B, C); } int NextLightest(int A, int B, int C, int D){ if (mem[3].find({A, B, C, D}) != mem[3].end()) return mem[3][{A, B, C, D}]; return mem[3][{A, B, C, D}] = getNextLightest(A, B, C, D); } void orderCoins() { for (int i = 0; i < 4; i++) mem[i].clear(); deque<int> a, b; for (int i = 1; i <= 6; i += 3){ int A = Lightest(i, i + 1, i + 2); int B = Median(i, i + 1, i + 2); int C = i ^ (i + 1) ^ (i + 2) ^ A ^ B; if (i == 1) a.push_back(A), a.push_back(B), a.push_back(C); else b.push_back(A), b.push_back(B), b.push_back(C); } int W[] = {0, 0, 0, 0, 0, 0}; W[0] = Lightest(a[0], b[0], a[1]); if (W[0] == a[0]) a.pop_front(); else b.pop_front(); for (int i = 1; i < 6; i++){ if (a.empty()){ W[i] = b.front(); b.pop_front(); continue; } if (b.empty()){ W[i] = a.front(); a.pop_front(); continue; } W[i] = Median(W[0], a.front(), b.front()); if (W[i] == a.front()) a.pop_front(); else b.pop_front(); } answer(W); }

Compilation message (stderr)

scales.cpp: In function 'void init(int)':
scales.cpp:6:15: warning: unused parameter 'T' [-Wunused-parameter]
    6 | void init(int T) {
      |           ~~~~^
#Verdict Execution timeMemoryGrader output
Fetching results...