# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
885522 | gustavo_d | Art Class (IOI13_artclass) | C++17 | 52 ms | 8056 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>
using namespace std;
typedef long long ll;
mt19937 randn(time(0));
struct Pixel {
int r, g, b;
Pixel() {
r=-1, g=-1; b=-1;
}
Pixel(int red, int green, int blue) {
r = red; g = green; b = blue;
}
bool operator != (Pixel &pixel) {
if (pixel.r != r or pixel.g != g or pixel.b != b) return true;
return false;
}
};
int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) {
Pixel img[H][W];
double green = 0;
for (int i=0; i<H; i++) {
for (int j=0; j<W; j++) {
img[i][j] = Pixel(R[i][j], G[i][j], B[i][j]);
if (img[i][j].g > max(img[i][j].r, img[i][j].b)) {
green++;
}
}
}
green /= H * W;
ll total_dist = 0;
for (int i=1; i<H-1; i++) {
for (int j=1; j<W-1; j++) {
vector<int> dif(3);
dif = {-1, 0, 1};
for (int di : dif) {
for (int dj : dif) {
total_dist += abs(img[i][j].r - img[i+di][j+dj].r);
total_dist += abs(img[i][j].g - img[i+di][j+dj].g);
total_dist += abs(img[i][j].b - img[i+di][j+dj].b);
}
}
}
}
total_dist /= ((ll)H*(ll)W); // 450+ é 3
int changes = 0;
for (int i=0; i<100; i++) {
int l = randn() % H;
Pixel last = img[l][0];
for (int j=1; j<W; j++) {
if (last != img[l][j]) changes++;
last = img[l][j];
}
}
changes /= W; // 95%+ é 2 ou 3
if (changes >= 95) {
if (total_dist >= 450) return 3; // dividir pelo tamanho da imagem
else return 2;
} else {
// 1 ou 4
if (total_dist <= 100) return 4;
else return 1;
}
return 4;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |