Submission #1304158

#TimeUsernameProblemLanguageResultExecution timeMemory
1304158kustov_vadim_533Art Class (IOI13_artclass)C++20
100 / 100
32 ms3344 KiB
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include "artclass.h"


using namespace std;

const int C1 = 180;

const int R2 = 96;
const int G2 = 90;
const int B2 = 56;
const int EPS2 = 20;


const int C3 = 40;
const int C4 = 7;

int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) {
	int white = 0;
	int green = 0;

	int mg = 0, mr = 0, mb = 0;

	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			white += R[i][j] >= C1 && G[i][j] >= C1 && B[i][j] >= C1;
			green += (R[i][j] >= R2 - EPS2) && (R[i][j] <= R2 + EPS2) && (B[i][j] >= B2 - EPS2) && (B[i][j] <= B2 + EPS2) && (G[i][j] >= G2 - EPS2) && (G[i][j] <= G2 + EPS2);
		}
	}

	int dr = 0, db = 0, dg = 0;
	for (int i = 0; i < H - 1; ++i) {
		for (int j = 0; j < W; ++j) {
			dr += abs(R[i][j] - R[i + 1][j]);
			dg += abs(G[i][j] - G[i + 1][j]);
			db += abs(B[i][j] - B[i + 1][j]);
		}
	}
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W - 1; ++j) {
			dr += abs(R[i][j] - R[i][j + 1]);
			dg += abs(G[i][j] - G[i][j + 1]);
			db += abs(B[i][j] - B[i][j + 1]);
		}
	}

//	cout << dr * 1.l / H / W << ' ';
//	cout << dg * 1.l / H / W << ' ';
//	cout << db * 1.l / H / W << '\n';

//	cout << mr * 1.l / H / W << ' ' << mg * 1.l / H / W << ' ' << mb * 1.l / H / W << '\n';

//	cout << green << ' ' << white << ' ' << H * W << '\n';
//	cout << (1.l) * green / H / W << ' ' << (1.l) * white / H / W << '\n';

	if (dr <= H * W * C4 || dg <= H * W * C4 || db <= H * W * C4) {
		return 4;
	}
	if (dr >= H * W * C3 || dg >= H * W * C3 || db >= H * W * C3) {
		return 3;
	}
	if (white >= H * W / 5) {
		return 1;
	}
	return 2;
}
#Verdict Execution timeMemoryGrader output
Fetching results...