# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1174473 | Lithanium | Art Class (IOI13_artclass) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
#include "artclass.h"
using namespace std;
int dt[505][505];
int getR(int RGB) { return (RGB >> 16) & 0xFF; }
int getG(int RGB) { return (RGB >> 8) & 0xFF; }
int getB(int RGB) { return RGB & 0xFF; }
int diff(int v1, int v2) {
return abs(getR(v1) - getR(v2)) + abs(getG(v1) - getG(v2)) + abs(getB(v1) - getB(v2));
}
int style(int R, int C, int r[500][500], g[500][500], b[500][500]) {
double stuff = 0;
for (int i = 1; i <= R; i ++) {
for (int j = 1; j <= C; j ++) {
dt[i][j] = ((r[i-1][j-1] << 8) + g[i-1][j-1]) << 8 + b[i-1][j-1];
if (i > 1) stuff += diff(dt[i][j], dt[i-1][j]);
if (j > 1) stuff += diff(dt[i][j], dt[i][j-1]);
}
}
stuff /= (double)R*C - R - C + 1;
if (stuff < 20) return 4;
else if (stuff < 46) return 1;
else if (stuff < 105) return 2;
else return 3;
// cout << test << ": " << stuff << "\n";
}