제출 #262281

#제출 시각아이디문제언어결과실행 시간메모리
262281eohomegrownapps미술 수업 (IOI13_artclass)C++14
38 / 100
107 ms6140 KiB
#include "artclass.h" #include <bits/stdc++.h> using namespace std; typedef long double ld; typedef long long ll; int size = 5; ld variance_data[4][9][3]={{{5.2824411498991095, 4.512041944986602, 3.9877517923801165},{4.109953000317832, 3.5251639497497593, 2.583329658299319},{4.0599414166232135, 3.214454227068947, 2.8794415155533164},{3.8187459500085006, 3.1251317597985238, 2.7258797446418295},{5.06922950704298, 4.781142315342459, 4.74983918981773},{5.66371141358102, 5.039144321323099, 3.1591464054282348},{4.552949101016332, 4.231009363821283, 4.527341573779875},{3.714847573114318, 3.659962363144, 3.586130927655374},{5.222052247854811, 2.4667857932999437, 2.195731839128234}},{{2.4666536176908296, 2.0629830581356257, 1.4699639183452446},{1.8134614491475296, 1.5684693984691638, 0.8818072983426067},{2.8088787223261735, 1.384751344990176, 0.5639851297542415},{1.0898217800933587, 1.2488571281603842, 0.7112425318447758},{1.1906425279446673, 1.0783969918239458, 0.3648423723862336},{2.347189370639743, 2.1565854065971775, 0.9459288624434778},{2.771386382611378, 2.0108536416244855, 1.388484315802357},{1.4457846705182154, 1.5124429273172633, 0.5888221288145326},{0.6145636792642141, 1.151643323705573, 0.713790344764571}},{{3.2062311073378176, 2.8479766283147865, 2.3068743850201923},{2.878344657926236, 2.1459527446561135, 1.486419588355472},{5.128999298228095, 4.886277457853918, 4.5377937973625055},{3.9024059559111812, 3.5278869922642926, 2.8621613468923983},{8.405299653224864, 5.763478847727209, 2.7424069110234894},{6.215745405462986, 5.441658127797566, 3.4619415128832145},{3.501482396033763, 3.307099720154386, 1.9938890500185074},{3.3780891002544386, 3.0475888551135184, 2.3440793528469936},{2.8942531168116536, 2.1591028437950093, 2.225162606299434}},{{1.961116047798011, 1.6635217303740293, 2.1619183579759826},{1.37826102050352, 0.10263979393525541, 0.11986603621904274},{10.059198546050265, 0.07316342656532622, 0.1047580932610654},{7.015737103375655, 3.9743478868863638, 2.10202623845263},{4.155151572803573, 0.8717720808252133, 0.3275836757344511},{5.634031846478673, 2.85864290484533, 0.3806889636843724},{0.37171422518729275, 0.3395648250852788, 0.4253246408979932},{6.4184832201406214, 2.1166633126075407, 1.1391979027732329},{7.862553785381836, 5.089142971379008, 0.978894867442586}}}; ld variance(ld sx, ld sxx, ll w, ll h){ ll n = w*h; return (sxx-(sx*sx)/(n))/(n-1); } int style(int h, int w, int r[500][500], int g[500][500], int b[500][500]) { //cout<<"processing\n"; ld variances[3] = {0,0,0}; int cnt = 0; for (int y = 0; y<h-size; y++){ for (int x = 0; x<w-size; x++){ cnt+=1; int sx[3]={0,0,0}; int sxx[3] = {0,0,0}; for (int ya = y; ya<y+size; ya++){ for (int xa = x; xa<x+size; xa++){ sx[0]+=r[ya][xa]; sxx[0]+=r[ya][xa]*r[ya][xa]; sx[1]+=g[ya][xa]; sxx[1]+=g[ya][xa]*g[ya][xa]; sx[2]+=b[ya][xa]; sxx[2]+=b[ya][xa]*b[ya][xa]; } } for (int i = 0; i<3; i++){ variances[i]+=variance(sx[i],sxx[i],w,h); } } } for (int c = 0; c<3; c++){ variances[c]/=(h-size)*(w-size); } //cout<<"computed\n"; ld minloss = 1e18; int minind = 0; for (int i = 0; i<4; i++){ for (int j = 0; j<9; j++){ ld loss = 0.0; for (int k = 0; k<3; k++){ ld diff = variance_data[i][j][k]-variances[k]; loss+=diff*diff; } if (loss<minloss){ minloss=loss; minind=i; } } } return minind+1; }
#Verdict Execution timeMemoryGrader output
Fetching results...