Submission #123118

#TimeUsernameProblemLanguageResultExecution timeMemory
123118MAMBAArt Class (IOI13_artclass)C++17
6 / 100
249 ms5980 KiB
#include <bits/stdc++.h>
//#include "grader.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;

	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 += D({R[i][j] , G[i][j] , B[i][j]} , {R[x][y] , G[x][y] , B[x][y]});
			}
		}
	invar /= cnt;

	if (dist > 145) return 1;
	if (invar < 20) return 4;
	if (invar < 50) return 2;
	return 3;
}
#Verdict Execution timeMemoryGrader output
Fetching results...