# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
103034 | naoai | Art Class (IOI13_artclass) | C++14 | 220 ms | 3480 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;
bool style4 (int H, int W, int R[500][500], int G[500][500], int B[500][500]) {
long long val = 0;
for (int i = 0; i < H; ++ i) {
int lg = 1;
for (int j = 1; j < W; ++ j) {
if (abs(R[i][j] - R[i][j - 1]) <= 20 && abs(G[i][j] - G[i][j - 1]) <= 20 && abs(B[i][j] - B[i][j - 1]) <= 20) {
++ lg;
} else {
val += 1LL * lg * lg;
lg = 1;
}
}
val += 1LL * lg * lg;
}
if (val > 0.8 * H * W * W) {
return 1;
}
val = 0;
for (int j = 0; j < W; ++ j) {
int lg = 1;
for (int i = 1; i < H; ++ i) {
if (abs(R[i][j] - R[i - 1][j]) <= 20 && abs(G[i][j] - G[i - 1][j]) <= 20 && abs(B[i][j] - B[i - 1][j]) <= 20) {
++ lg;
} else {
val += 1LL * lg * lg;
lg = 1;
}
}
val += 1LL * lg * lg;
}
if (val > 0.8 * W * H * H) {
return 1;
}
return 0;
}
bool style2 (int H, int W, int R[500][500], int G[500][500], int B[500][500]) {
int cnt = 0;
int ct = 7;
for (int i = 0; i < H; ++ i) {
for (int j = 0; j < W; ++ j) {
int mx = -1, mn = 256;
for (int p = max(0, i - ct); p < min(H, i + ct); ++ p) {
for (int q = max(0, j - ct); q < min(W, j + ct); ++ q) {
mx = max(mx, (R[p][q] + B[p][q] + G[p][q]) / 3);
mn = min(mn, (R[p][q] + B[p][q] + G[p][q]) / 3);
}
}
if (mx - mn < 100) {
++ cnt;
}
}
}
if (cnt > 0.60 * H * W)
return 1;
return 0;
}
bool style1 (int H, int W, int R[500][500], int G[500][500], int B[500][500]) {
int cnt = 0;
int ct = 10;
for (int i = 0; i < H; ++ i) {
for (int j = 0; j < W; ++ j) {
bool ok = 1;
for (int p = max(0, i - ct); p < min(H, i + ct) && ok; ++ p) {
for (int q = max(0, j - ct); q < min(W, j + ct) && ok; ++ q) {
if (abs(R[i][j] - R[p][q]) + abs(G[i][j] - G[p][q]) + abs(B[i][j] - B[p][q]) > 30)
ok = 0;
}
}
cnt += ok;
}
}
//cout << 100.0 * cnt / (H * W) << "%\n";
if (cnt > 0.01 * H * W)
return 1;
return 0;
}
int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) {
if (style4(H, W, R, G, B))
return 4;
if (style1(H, W, R, G, B))
return 1;
if (style2(H, W, R, G, B))
return 2;
return 3;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |