Submission #1031338

#TimeUsernameProblemLanguageResultExecution timeMemory
1031338Dan4LifeScales (IOI15_scales)C++17
0 / 100
1 ms604 KiB
#include "scales.h" #include <bits/stdc++.h> using namespace std; #define pb push_back #define sz(a) (int)a.size() #define all(a) begin(a),end(a) using ll = long long; using vi = vector<int>; using ar2 = array<int,2>; int W[] = {0, 1, 2, 3, 4, 5, 6}; int getInd(int x){ for(int i = 1; i <= 6; i++) if(W[i]==x) return i; return 0; } int getMx[10][10][10]; int getMax(int _a, int _b, int _c){ int a=_a, b=_b, c=_c; if(a>b)swap(a,b); if(b>c)swap(b,c); if(a>b)swap(a,b); if(getMx[a][b][c]) return getMx[a][b][c]; return getMx[a][b][c]=getHeaviest(a,b,c); } int getMn[10][10][10]; int getMin(int _a, int _b, int _c){ int a=_a, b=_b, c=_c; if(a>b)swap(a,b); if(b>c)swap(b,c); if(a>b)swap(a,b); if(getMn[a][b][c]) return getMn[a][b][c]; return getMn[a][b][c]=getLightest(a,b,c); } int getMed[10][10][10]; int getMiddle(int _a, int _b, int _c){ int a=_a, b=_b, c=_c; if(a>b)swap(a,b); if(b>c)swap(b,c); if(a>b)swap(a,b); if(getMed[a][b][c]) return getMed[a][b][c]; return getMed[a][b][c]=getMedian(a,b,c); } int getNxt[10][10][10][10]; int getNext(int _a, int _b, int _c, int _d){ int a=_a, b=_b, c=_c, d=d; if(a>b)swap(a,b); if(b>c)swap(b,c); if(a>b)swap(a,b); if(getNxt[a][b][c][d]) return getNxt[a][b][c][d]; return getNxt[a][b][c][d]=getNextLightest(a,b,c,d); } void init(int T) {} bool vis[10]; void orderCoins() { for(int i = 1; i <= 6; i++) W[i]=i; int cur, cur2, cur3; cur = getMax(W[1],W[2],W[3]); cur2 = getMax(W[4],W[5],W[6]), cur3=1; while(cur3==cur or cur3==cur2) cur3++; cur3 = getMax(cur,cur2,cur3); swap(W[6],W[getInd(cur3)]); vis[W[6]]=1; cur = getMax(W[1],W[2],W[3]); cur3 = getMax(cur,W[4],W[5]); swap(W[5],W[getInd(cur3)]); vis[W[5]]=1; cur = getMax(W[1],W[2],W[3]), cur2 = 1; while(cur2==cur or vis[cur2]) cur2++; cur3 = getMax(cur,cur2,W[4]); swap(W[4],W[getInd(cur3)]); cur = getMax(W[1],W[2],W[3]); swap(W[3],W[getInd(cur)]); cur = getMin(W[1],W[2],W[3]); if(cur!=W[1]) swap(W[1],W[2]); int ans[] = {W[1],W[2],W[3],W[4],W[5],W[6]}; answer(ans); }

Compilation message (stderr)

scales.cpp: In function 'int getNext(int, int, int, int)':
scales.cpp:51:41: warning: unused parameter '_d' [-Wunused-parameter]
   51 | int getNext(int _a, int _b, int _c, int _d){
      |                                     ~~~~^~
scales.cpp: In function 'void init(int)':
scales.cpp:60:15: warning: unused parameter 'T' [-Wunused-parameter]
   60 | void init(int T) {}
      |           ~~~~^
scales.cpp: In function 'int getNext(int, int, int, int)':
scales.cpp:52:24: warning: 'd' is used uninitialized in this function [-Wuninitialized]
   52 |  int a=_a, b=_b, c=_c, d=d;
      |                        ^
#Verdict Execution timeMemoryGrader output
Fetching results...