# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
434898 | QCFium | Art Class (IOI13_artclass) | C++14 | 105 ms | 3308 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 value3(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]);
};
const int THRESHOLD = 50;
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 < THRESHOLD) r0 += cur_diff;
}
}
return r0 * 10 / h / w;
}
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 r3 = value3(h, w, r, g, b);
if (r1 <= 15) return 4;
if (r1 >= 400) return 3;
if (r3 <= 125) return 1;
else return 2;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |