# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
434879 | QCFium | Art Class (IOI13_artclass) | C++14 | 122 ms | 6176 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 <bits/stdc++.h>
#include "artclass.h"
int ri() {
int n;
scanf("%d", &n);
return n;
}
int value1(int h, int w, int r[500][500], int g[500][500], int b[500][500]) {
auto diff = [&] (int i0, int j0, int i1, int j1) {
return std::abs(r[i0][j0] - r[i1][j1]) + std::abs(g[i0][j0] - g[i1][j1]) + std::abs(b[i0][j0] - b[i1][j1]);
};
int r0 = 0;
for (int i = 0; i + 1 < h; i++) {
for (int j = 0; j < w; j++) {
int cur_diff = diff(i, j, i + 1, j);
if (cur_diff > 40) r0 += cur_diff;
}
}
int r1 = 0;
for (int i = 0; i < h; i++) {
for (int j = 0; j + 1 < w; j++) {
int cur_diff = diff(i, j, i, j + 1);
if (cur_diff > 40) r1 += cur_diff;
}
}
int r2 = 0;
for (int i = 0; i + 1 < h; i++) {
for (int j = 0; j + 1 < w; j++) {
int cur_diff = diff(i, j, i + 1, j + 1);
if (cur_diff > 40) r2 += cur_diff;
}
}
return std::min({r0, r1, r2}) * 10 / h / w;
}
int value2(int h, int w, int r[500][500], int g[500][500], int b[500][500]) {
double ra = 0;
double ga = 0;
double ba = 0;
for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) {
ra += r[i][j];
ga += g[i][j];
ba += b[i][j];
}
ra /= h * w;
ga /= h * w;
ba /= h * w;
double sd = 0;
for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) {
double tmp = std::abs(ra - r[i][j]) + std::abs(ga - g[i][j]) + std::abs(ba - b[i][j]);
sd += tmp * tmp;
}
sd /= h * w;
return sd;
}
int style(int h, int w, int r[500][500], int g[500][500], int b[500][500]) {
int r1 = value1(h, w, r, g, b);
int r2 = value2(h, w, r, g, b);
if (r1 <= 15) return 4;
if (r1 >= 400) return 3;
if (r2 <= 33000) return 2;
return 1;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |