# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
658359 | cristi_a | Art Class (IOI13_artclass) | C++17 | 76 ms | 5352 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"
using namespace std;
int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) {
static const int dx[] = {0, 0, -1, 1};
static const int dy[] = {1, -1, 0, 0};
static const int area = H * W;
auto in = [&](int a, int b) {
if(a < 0 or a >= H or b < 0 or b >= W) return false;
return true;
};
int red_sum = 0;
int green_sum = 0;
int blue_sum = 0;
int salt_and_pepper = 0;
for(int i=0; i<H; i++)
for(int j=0; j<W; j++) {
red_sum += R[i][j];
green_sum += G[i][j];
blue_sum += B[i][j];
for(int k=0; k<4; k++) {
int ni = i + dx[k];
int nj = j + dy[k];
if(!in(ni, nj)) continue;
int difs = abs(R[i][j] - R[ni][nj]) +
abs(G[i][j] - G[ni][nj]) +
abs(B[i][j] - B[ni][nj]);
if(difs >= 140) salt_and_pepper++;
}
}
double snp_percent = 1.00 * salt_and_pepper / (2.00 * area) * 100.00;
double red_avg = 1.00 * red_sum / (1.00 * area);
double blue_avg = 1.00 * blue_sum / (1.00 * area);
double green_avg = 1.00 * green_sum / (1.00 * area);
double green_diff_sum = (green_avg - blue_avg) + (green_avg - red_avg);
if(snp_percent <= 0.70) return 4;
if(snp_percent >= 25.00) return 3;
if(green_diff_sum >= 19.00 and snp_percent <= 15.00) return 2;
return 1;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |