# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
772901 | alontanay | Art Class (IOI13_artclass) | C++14 | 471 ms | 6092 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;
double noise(int H, int W, int R[500][500], int G[500][500], int B[500][500]) {
double res = 1e18;
const int NOISE_RAD = 25;
const int PAD = 0;
for (int er = NOISE_RAD + PAD; er < H - PAD; er++) {
int sr = er - NOISE_RAD;
for (int ec = NOISE_RAD + PAD; ec < W - PAD; ec++) {
int sc = ec - NOISE_RAD;
double score = 0;
double rSum = 0, gSum = 0, bSum = 0;
for (int r = sr; r < er; r++) {
for (int c = sc; c < ec; c++) {
rSum += R[r][c];
gSum += G[r][c];
bSum += B[r][c];
// cout << R[r][c] << " ";
}
// cout << endl;
}
double aveR = rSum / (NOISE_RAD * NOISE_RAD);
double aveG = gSum / (NOISE_RAD * NOISE_RAD);
double aveB = bSum / (NOISE_RAD * NOISE_RAD);
// cout << aveR << " " << aveG << " " << aveB << " " << sr << " " <<
// er
// << " " << sc << " " << ec << endl;
for (int r = sr; r < er; r++) {
for (int c = sc; c < ec; c++) {
double difR = (aveR - R[r][c]);
double difG = (aveG - G[r][c]);
double difB = (aveB - B[r][c]);
score += abs(difR) + abs(difG) + abs(difB);
}
}
// cout << score << endl;
res = min(res, score);
}
}
return res;
}
int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) {
double nos = noise(H, W, R, G, B);
if (nos < 2500) {
int blackL = W;
int blackR = 0;
int blackU = H;
int blackD = 0;
for (int r = 0; r < H; r++) {
for (int c = 0; c < W; c++) {
if (R[r][c] + G[r][c] + B[r][c] < 60 && R[r][c] < 50 &&
G[r][c] < 50 && B[r][c] < 50) {
blackL = min(blackL, c);
blackR = max(blackR, c);
blackU = min(blackU, r);
blackD = max(blackD, r);
}
}
}
const int PAD = 200;
// cout << "!" << blackL << " " << W - blackR << " " << blackU << " "
// << H - blackD << endl;
if (blackL < PAD && blackR > W - PAD && blackU < PAD &&
blackD > H - PAD) {
return 1;
} else {
return 4;
}
}
if (nos > 12000) {
return 3;
} else {
return 2;
}
double sumR = 0, sumG = 0, sumB = 0;
for (int r = 0; r < H; r++) {
for (int c = 0; c < W; c++) {
sumR += R[r][c];
sumG += G[r][c];
sumB += B[r][c];
}
}
sumR /= (H * W);
sumG /= (H * W);
sumB /= (H * W);
if (sumG > max(sumR, sumB) - 15) {
return 2;
}
srand(time(0));
vector<int> opts = {1, 4};
return opts[rand() % 2];
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |