Submission #868709

#TimeUsernameProblemLanguageResultExecution timeMemory
868709anachorArt Class (IOI13_artclass)C++14
67 / 100
234 ms3516 KiB
#include "artclass.h" #include<bits/stdc++.h> int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) { using namespace std; const int K = 500; int d = 1; auto exists = [&](int x, int y) { return 0 <= x && x < K && 0 <= y && y < K; }; auto diff = [&](int x, int y, int X, int Y) { return ((abs(R[x][y] - R[X][Y])) + (abs(G[X][Y] - G[x][y])) + (abs(B[X][Y] - B[x][y])))/3.0; }; auto avg = [&] (int d) { double ans = 0; for (int i=0; i<K; i++) { for (int j=0; j<K; j++) { double dd = 0; int cc = 0; for (int dx=-d; dx<=d; dx++) { for (int dy=-d; dy<=d; dy++) { int nx = i+dx, ny = j+dy; if (!exists(nx, ny)) continue; int zz = abs(dx) + abs(dy); dd += diff(i, j, nx, ny)/(1<<zz); cc+= 1.0/(1<<zz); } } ans += dd/cc; } } ans /= K*K; return ans; }; double L1 = avg(1), L2 = avg(5); cerr<<setprecision(1)<<fixed<<L1<<" "<<L2<<endl; if (L2 < 35) return 4; if (L2 < 60) return 1; if (L2 < 120) return 2; return 3; }

Compilation message (stderr)

artclass.cpp: In function 'int style(int, int, int (*)[500], int (*)[500], int (*)[500])':
artclass.cpp:8:9: warning: unused variable 'd' [-Wunused-variable]
    8 |     int d = 1;
      |         ^
#Verdict Execution timeMemoryGrader output
Fetching results...