# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
868709 | anachor | Art Class (IOI13_artclass) | C++14 | 234 ms | 3516 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |