Submission #762207

#TimeUsernameProblemLanguageResultExecution timeMemory
762207SanguineChameleonArt Class (IOI13_artclass)C++17
71 / 100
54 ms5348 KiB
#include "artclass.h" #include <bits/stdc++.h> using namespace std; int A[4][4][4]; int E[4][4][4][4]; int style(int N, int M, int R[500][500], int G[500][500], int B[500][500]) { E[0][0][0][0] = 244813; E[0][0][0][1] = 8517; E[0][0][0][2] = 5539; E[0][0][0][3] = 0; E[0][0][1][0] = 2298; E[0][0][1][1] = 1060; E[0][0][1][2] = 19649; E[0][0][1][3] = 5589; E[0][0][2][0] = 0; E[0][0][2][1] = 0; E[0][0][2][2] = 1698; E[0][0][2][3] = 3567; E[0][0][3][0] = 0; E[0][0][3][1] = 0; E[0][0][3][2] = 0; E[0][0][3][3] = 0; E[0][1][0][0] = 16537; E[0][1][0][1] = 4815; E[0][1][0][2] = 2981; E[0][1][0][3] = 0; E[0][1][1][0] = 13945; E[0][1][1][1] = 24817; E[0][1][1][2] = 35834; E[0][1][1][3] = 3345; E[0][1][2][0] = 6; E[0][1][2][1] = 1079; E[0][1][2][2] = 1683; E[0][1][2][3] = 7740; E[0][1][3][0] = 0; E[0][1][3][1] = 0; E[0][1][3][2] = 0; E[0][1][3][3] = 3; E[0][2][0][0] = 39868; E[0][2][0][1] = 599; E[0][2][0][2] = 0; E[0][2][0][3] = 0; E[0][2][1][0] = 7549; E[0][2][1][1] = 5137; E[0][2][1][2] = 845; E[0][2][1][3] = 7; E[0][2][2][0] = 15837; E[0][2][2][1] = 9152; E[0][2][2][2] = 67642; E[0][2][2][3] = 28021; E[0][2][3][0] = 0; E[0][2][3][1] = 19; E[0][2][3][2] = 1394; E[0][2][3][3] = 12436; E[0][3][0][0] = 51470; E[0][3][0][1] = 124; E[0][3][0][2] = 0; E[0][3][0][3] = 0; E[0][3][1][0] = 107987; E[0][3][1][1] = 40068; E[0][3][1][2] = 147; E[0][3][1][3] = 0; E[0][3][2][0] = 39343; E[0][3][2][1] = 6457; E[0][3][2][2] = 10456; E[0][3][2][3] = 2214; E[0][3][3][0] = 129517; E[0][3][3][1] = 15040; E[0][3][3][2] = 29763; E[0][3][3][3] = 1036893; E[1][0][0][0] = 378463; E[1][0][0][1] = 580; E[1][0][0][2] = 0; E[1][0][0][3] = 0; E[1][0][1][0] = 115370; E[1][0][1][1] = 40194; E[1][0][1][2] = 0; E[1][0][1][3] = 0; E[1][0][2][0] = 1; E[1][0][2][1] = 40; E[1][0][2][2] = 0; E[1][0][2][3] = 0; E[1][0][3][0] = 0; E[1][0][3][1] = 0; E[1][0][3][2] = 0; E[1][0][3][3] = 0; E[1][1][0][0] = 91609; E[1][1][0][1] = 690; E[1][1][0][2] = 0; E[1][1][0][3] = 0; E[1][1][1][0] = 391301; E[1][1][1][1] = 124576; E[1][1][1][2] = 496; E[1][1][1][3] = 0; E[1][1][2][0] = 6181; E[1][1][2][1] = 25416; E[1][1][2][2] = 3638; E[1][1][2][3] = 0; E[1][1][3][0] = 0; E[1][1][3][1] = 0; E[1][1][3][2] = 1; E[1][1][3][3] = 0; E[1][2][0][0] = 1365; E[1][2][0][1] = 2; E[1][2][0][2] = 0; E[1][2][0][3] = 0; E[1][2][1][0] = 95809; E[1][2][1][1] = 37743; E[1][2][1][2] = 264; E[1][2][1][3] = 0; E[1][2][2][0] = 47592; E[1][2][2][1] = 121824; E[1][2][2][2] = 92300; E[1][2][2][3] = 10001; E[1][2][3][0] = 58; E[1][2][3][1] = 502; E[1][2][3][2] = 2946; E[1][2][3][3] = 3043; E[1][3][0][0] = 1; E[1][3][0][1] = 0; E[1][3][0][2] = 0; E[1][3][0][3] = 0; E[1][3][1][0] = 1284; E[1][3][1][1] = 781; E[1][3][1][2] = 0; E[1][3][1][3] = 0; E[1][3][2][0] = 4276; E[1][3][2][1] = 24708; E[1][3][2][2] = 62491; E[1][3][2][3] = 741; E[1][3][3][0] = 471; E[1][3][3][1] = 2416; E[1][3][3][2] = 27904; E[1][3][3][3] = 39922; E[2][0][0][0] = 189774; E[2][0][0][1] = 5117; E[2][0][0][2] = 0; E[2][0][0][3] = 0; E[2][0][1][0] = 4747; E[2][0][1][1] = 3536; E[2][0][1][2] = 0; E[2][0][1][3] = 0; E[2][0][2][0] = 0; E[2][0][2][1] = 0; E[2][0][2][2] = 0; E[2][0][2][3] = 0; E[2][0][3][0] = 0; E[2][0][3][1] = 0; E[2][0][3][2] = 0; E[2][0][3][3] = 0; E[2][1][0][0] = 33349; E[2][1][0][1] = 3800; E[2][1][0][2] = 0; E[2][1][0][3] = 0; E[2][1][1][0] = 74404; E[2][1][1][1] = 234735; E[2][1][1][2] = 6492; E[2][1][1][3] = 0; E[2][1][2][0] = 2; E[2][1][2][1] = 6780; E[2][1][2][2] = 5190; E[2][1][2][3] = 0; E[2][1][3][0] = 0; E[2][1][3][1] = 0; E[2][1][3][2] = 19; E[2][1][3][3] = 1; E[2][2][0][0] = 1656; E[2][2][0][1] = 645; E[2][2][0][2] = 0; E[2][2][0][3] = 0; E[2][2][1][0] = 14541; E[2][2][1][1] = 59698; E[2][2][1][2] = 5476; E[2][2][1][3] = 0; E[2][2][2][0] = 1966; E[2][2][2][1] = 91676; E[2][2][2][2] = 172788; E[2][2][2][3] = 855; E[2][2][3][0] = 0; E[2][2][3][1] = 0; E[2][2][3][2] = 3358; E[2][2][3][3] = 1248; E[2][3][0][0] = 337; E[2][3][0][1] = 0; E[2][3][0][2] = 0; E[2][3][0][3] = 0; E[2][3][1][0] = 21189; E[2][3][1][1] = 1703; E[2][3][1][2] = 236; E[2][3][1][3] = 0; E[2][3][2][0] = 6348; E[2][3][2][1] = 19513; E[2][3][2][2] = 55574; E[2][3][2][3] = 500; E[2][3][3][0] = 1954; E[2][3][3][1] = 12454; E[2][3][3][2] = 120800; E[2][3][3][3] = 171039; E[3][0][0][0] = 173691; E[3][0][0][1] = 18865; E[3][0][0][2] = 0; E[3][0][0][3] = 0; E[3][0][1][0] = 17863; E[3][0][1][1] = 30850; E[3][0][1][2] = 96478; E[3][0][1][3] = 0; E[3][0][2][0] = 0; E[3][0][2][1] = 0; E[3][0][2][2] = 6; E[3][0][2][3] = 0; E[3][0][3][0] = 0; E[3][0][3][1] = 0; E[3][0][3][2] = 0; E[3][0][3][3] = 0; E[3][1][0][0] = 161482; E[3][1][0][1] = 202; E[3][1][0][2] = 0; E[3][1][0][3] = 0; E[3][1][1][0] = 1170; E[3][1][1][1] = 8412; E[3][1][1][2] = 9114; E[3][1][1][3] = 0; E[3][1][2][0] = 0; E[3][1][2][1] = 0; E[3][1][2][2] = 1070; E[3][1][2][3] = 0; E[3][1][3][0] = 0; E[3][1][3][1] = 0; E[3][1][3][2] = 0; E[3][1][3][3] = 0; E[3][2][0][0] = 82337; E[3][2][0][1] = 120; E[3][2][0][2] = 0; E[3][2][0][3] = 0; E[3][2][1][0] = 21847; E[3][2][1][1] = 100425; E[3][2][1][2] = 377; E[3][2][1][3] = 0; E[3][2][2][0] = 27274; E[3][2][2][1] = 27515; E[3][2][2][2] = 14412; E[3][2][2][3] = 181; E[3][2][3][0] = 0; E[3][2][3][1] = 0; E[3][2][3][2] = 1087; E[3][2][3][3] = 2559; E[3][3][0][0] = 184255; E[3][3][0][1] = 149; E[3][3][0][2] = 0; E[3][3][0][3] = 0; E[3][3][1][0] = 118460; E[3][3][1][1] = 33637; E[3][3][1][2] = 130; E[3][3][1][3] = 0; E[3][3][2][0] = 168979; E[3][3][2][1] = 45343; E[3][3][2][2] = 4166; E[3][3][2][3] = 309; E[3][3][3][0] = 19789; E[3][3][3][1] = 8080; E[3][3][3][2] = 38199; E[3][3][3][3] = 54167; for (int r = 0; r < 4; r++) { for (int g = 0; g < 4; g++) { for (int b = 0; b < 4; b++) { A[r][g][b] = 1; } } } for (int i = 0; i < N; i++) { for (int j = 0; j < M; j++) { A[R[i][j] / 64][G[i][j] / 64][B[i][j] / 64]++; } } pair<long double, int> res = make_pair(1e18L, -1); for (int X = 0; X < 4; X++) { long double score = 0.0L; int totA = 0; int totE = 0; for (int r = 0; r < 4; r++) { for (int g = 0; g < 4; g++) { for (int b = 0; b < 4; b++) { totA += A[r][g][b]; totE += E[X][r][g][b] + 1; } } } for (int r = 0; r < 4; r++) { for (int g = 0; g < 4; g++) { for (int b = 0; b < 4; b++) { long double exp = 1.0L * (E[X][r][g][b] + 1) / totE * totA; score += (exp - A[r][g][b]) * (exp - A[r][g][b]) / exp; } } } res = min(res, make_pair(score, X + 1)); } return res.second; }
#Verdict Execution timeMemoryGrader output
Fetching results...