제출 #69869

#제출 시각아이디문제언어결과실행 시간메모리
69869FLDutchmanArt Class (IOI13_artclass)C++14
0 / 100
147 ms66560 KiB
#include "artclass.h"
#include <bits/stdc++.h>
using namespace std;

typedef int INT;

#define FOR(i,l,r) for(int i = (l); i < (r); i++)
#define fst first
#define snd second
#define pb push_back
#define mp make_pair
#define V vector
#define int long long

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;

const int NMAX = 1e5+10;

double sqr(double x) {return x * x;}

struct color{
	double r, g, b;
	double l;
	color (){}
	color (int r, int g, int b) : r(r), g(g), b(b) {l = sqrt(r*r + g*g + b*b);}
	int operator- (const color &c) {
		//cerr<<r/l<<endl;
		return abs(l-c.l); //abs(r/l-c.r/c.l) + abs(g/l-c.g/c.l) + abs(b/l-c.b/c.l);
	}
};

V<V<color>> canvas(0);		
int H = 0, W = 0;	

double diff(){

	double tot = 0;
	double div = 0;
	FOR(i, 1, H) FOR(j, 1, W){
		if(i > 0) {tot += canvas[i][j] - canvas[i-1][j]; div++;}
		if(j > 0) {tot += canvas[i][j] - canvas[i][j-1]; div++;}
	}
	return tot / div;
}


double diff(string s){
	ifstream fin(s);
	fin >> H >> W;
	canvas.assign(H, V<color>(W));
	FOR(i, 0, H) FOR(j, 0, W){
		int r,g,b;
		fin>>r>>g>>b;
		canvas[i][j] = {r, g, b};
	}
	double tot = 0;
	double div = 0;
	FOR(i, 0, H) FOR(j, 0, W){
		if(i > 0) {tot += canvas[i][j] - canvas[i-1][j]; div += 1;}
		if(j > 0) {tot += canvas[i][j] - canvas[i][j-1]; div += 1;}
	}
	return tot / div;
}



INT style(INT h, INT w, INT R[500][500], INT G[500][500], INT B[500][500]) {
	H=h; W=w;
	canvas.assign(H, V<color>(W));

	FOR(i, 0, H) FOR(j, 0, W){
		canvas[i][j] = color(R[i][j], G[i][j], B[i][j]);
	}
	double k = 10 * diff();
	if(k <= 40) return 4;
	if(k <= 115) return 1;
	if(k <= 300) return 2;
	return 3;
}

#Verdict Execution timeMemoryGrader output
Fetching results...