Submission #123106

#TimeUsernameProblemLanguageResultExecution timeMemory
123106MAMBA미술 수업 (IOI13_artclass)C++17
36 / 100
238 ms4216 KiB
#include <bits/stdc++.h>
#include "artclass.h"

using namespace std;

#define rep(i , j , k) for (int i = j; i < k; i++)

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

inline double D(vector<int> a, vector<int> b) {
	 return sqrt((sq(a[0] - b[0]) + sq(a[1] - b[1]) + sq(a[2] - b[2])) / 3.0);
}

int dx[7] = {0 , 0 , 1 , 1 , 1 , 2 , 2};
int dy[7] = {1 , 2 , 0 , 1 , 2 , 0 , 1};

int style(int H ,  int W , int R[500][500],  int G[500][500], int B[500][500]) {
	double dist = 0;
	rep(i , 0 , H)
		rep(j , 0 , W)
			dist += D({R[i][j] , G[i][j] , B[i][j]} , {0 , 255 , 0});
	dist /= H * W;
//	cout << dist << endl;

	double invar = 0;
	int cnt = 0;

	rep(i , 0 , H)
		rep(j , 0 , W) 
		rep(z , 0 , 7) {
			int x = i + dx[z];
			int y = j + dy[z];
			if (x < H && y < W) {
				cnt++;
				invar += sqrt(D({R[i][j] , G[i][j] , B[i][j]} , {R[x][y] , G[x][y] , B[x][y]}));
			}
		}
	invar /= cnt;
//	cout << invar << endl;

	if (dist < 145 && invar < 3.5)
		return 4;
	if (dist > 150) 
		return 1;
	if (invar < 5.5) return 2;
		return 3;

}
#Verdict Execution timeMemoryGrader output
Fetching results...