Submission #1031411

#TimeUsernameProblemLanguageResultExecution timeMemory
1031411Dan4LifeScales (IOI15_scales)C++17
0 / 100
1 ms444 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 A,B,C,D,E,F; 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){ 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){ 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){ 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){ 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) {} void sort3in2(int a, int b, int c){ int A = W[a], B = W[b], C = W[c]; int med = getMiddle(W[a],W[b],W[c]); int mx = getMax(W[a],W[b],W[c]); int mn = med^mx^A^B^C; W[a]=mn;W[b]=med;W[c]=mx; } void upd_vals(){ A=W[1],B=W[2],C=W[3],D=W[4],E=W[5],F=W[6]; } void orderCoins() { memset(getMx,0,sizeof(getMx)); memset(getMn,0,sizeof(getMn)); memset(getMed,0,sizeof(getMed)); memset(getNxt,0,sizeof(getNxt)); for(int i = 1; i <= 6; i++) W[i]=i; sort3in2(1,2,3); sort3in2(4,5,6); // a<b<c d<e<f upd_vals(); if(getMin(A,D,E)!=A){ W[1]=D,W[2]=E,W[3]=F; W[4]=A,W[5]=B,W[6]=C; } upd_vals(); int nx = getNext(A,B,C,D), checklst3=0; if(nx==A){ int med = getMiddle(C,D,E); if(med!=D) W[1]=D,W[2]=A,W[3]=B,W[4]=C, checklst3=1; } else{ if(nx==C) W[1]=A,W[2]=B,W[3]=D; else W[1]=A,W[2]=D,W[3]=B; W[4]=C; checklst3=1; } upd_vals(); if(checklst3){ int med = getMiddle(W[4],W[5],W[6]); C=W[4],E=W[5],F=W[6]; if(med==E) W[4]=C,W[5]=E,W[6]=F; else if(med==F) W[4]=E,W[5]=F,W[6]=C; else W[4]=E,W[5]=C,W[6]=F; } int ans[] = {W[1],W[2],W[3],W[4],W[5],W[6]}; answer(ans); }

Compilation message (stderr)

scales.cpp: In function 'void init(int)':
scales.cpp:57:15: warning: unused parameter 'T' [-Wunused-parameter]
   57 | void init(int T) {}
      |           ~~~~^
scales.cpp: In function 'void sort3in2(int, int, int)':
scales.cpp:60:6: warning: declaration of 'A' shadows a global declaration [-Wshadow]
   60 |  int A = W[a], B = W[b], C = W[c];
      |      ^
scales.cpp:13:5: note: shadowed declaration is here
   13 | int A,B,C,D,E,F;
      |     ^
scales.cpp:60:16: warning: declaration of 'B' shadows a global declaration [-Wshadow]
   60 |  int A = W[a], B = W[b], C = W[c];
      |                ^
scales.cpp:13:7: note: shadowed declaration is here
   13 | int A,B,C,D,E,F;
      |       ^
scales.cpp:60:26: warning: declaration of 'C' shadows a global declaration [-Wshadow]
   60 |  int A = W[a], B = W[b], C = W[c];
      |                          ^
scales.cpp:13:9: note: shadowed declaration is here
   13 | int A,B,C,D,E,F;
      |         ^
#Verdict Execution timeMemoryGrader output
Fetching results...