Submission #123159

#TimeUsernameProblemLanguageResultExecution timeMemory
123159MAMBAArt Class (IOI13_artclass)C++17
87 / 100
234 ms6212 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 (invar < 1.9)
        		return 4;
        	if (dist > 150) 
        		return 1;
        	if (invar < 4.5) return 2;
        		return 3;
         
        }
#Verdict Execution timeMemoryGrader output
Fetching results...