Submission #396398

#TimeUsernameProblemLanguageResultExecution timeMemory
396398wmrmrArt Class (IOI13_artclass)C++17
3 / 100
99 ms3284 KiB
#include "artclass.h"
#include <bits/stdc++.h>
using namespace std;

int MOD(int x)
{
	if(x>0) return x;
	return -x;
}

int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) {
	bool style4 = 1;
    for(int i=0;i<H;i++)
    {
    	int cnt,sR,sG,sB; cnt = sR = sG = sB = 0;
    	float w = W;
    	for(int j=0;j<W;j++)
    	{
    		sR += R[i][j];
    		sG += G[i][j];
    		sB += B[i][j];
		}
		int aR = sR/W, aG = sG/W, aB = sB/W;
		for(int j=0;j<W;j++)
		{
			if( MOD(R[i][j]-aR) <= 15 && MOD(G[i][j]-aG) <= 15 && MOD(B[i][j]-aB) <= 15 ) cnt++;
		}
		float ind = cnt;
		if(cnt < w*0.7) { style4 = 0; break; }
	}
	if(style4) return 4;
	int cntW = 0;
	for(int i=0;i<H;i++) for(int j=0;j<W;j++)
	{
		if(R[i][j] <= 15 && G[i][j] <= 15 && B[i][j] <= 15) cntW++;
	}
	if(cntW >= H*W/10) return 1;
	srand(time(0));
	return (rand()%2) ? 2 : 3;
}

Compilation message (stderr)

artclass.cpp: In function 'int style(int, int, int (*)[500], int (*)[500], int (*)[500])':
artclass.cpp:28:9: warning: unused variable 'ind' [-Wunused-variable]
   28 |   float ind = cnt;
      |         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...