# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
868708 | anachor | Art Class (IOI13_artclass) | C++14 | 54 ms | 3524 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(G[X][Y] - G[x][y]))/3.0;
};
auto var = [&] (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;
dd += diff(i, j, nx, ny);
cc++;
}
}
ans += dd/cc;
}
}
ans /= K*K;
return ans;
};
double dd = var(1);
if (dd < 6) return 4;
return 0;
if (dd < 18) return 1;
if (dd < 27) return 2;
return 3;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |