2014-06-20
■ IOI 2013 ArtClass
実験する過程で、
全マスのR,G,Bの2乗和の平均と、隣接したマス同士のR,G,Bの差の2乗和の平均を求めると、
隣接したマス同士のR,G,Bの差の2乗和の平均が極端にでかい->3
隣接したマス同士のR,G,Bの差の2乗和の平均が極端に小さい->4
全マスのBの2乗和の平均が小さい->2
全マスのBの2乗和の平均が大きい->1
となる気がしたので出したら98点。基準をいじって2回目で100点取れた。
#include#include using namespace std; int hoge[505][505],h,w,t; int getR(int RGB) { return (RGB >> 16) & 0xFF; } int getG(int RGB) { return (RGB >> 8) & 0xFF; } int getB(int RGB) { return RGB & 0xFF; } int main() { scanf("%d",&t); while(t--) { scanf("%d%d",&h,&w); for(int i=0;i for(int j=0;j "%d",&hoge[i][j]); double R=0,G=0,B=0; for(int i=0;i for(int j=0;j if(i) { R += (double)(getR(hoge[i][j])-getR(hoge[i-1][j]))*(double)(getR(hoge[i][j])-getR(hoge[i-1][j])); G += (double)(getG(hoge[i][j])-getG(hoge[i-1][j]))*(double)(getG(hoge[i][j])-getG(hoge[i-1][j])); B += (double)(getB(hoge[i][j])-getB(hoge[i-1][j]))*(double)(getB(hoge[i][j])-getB(hoge[i-1][j])); } if(i double)(getR(hoge[i][j])-getR(hoge[i+1][j]))*(double)(getR(hoge[i][j])-getR(hoge[i+1][j])); G += (double)(getG(hoge[i][j])-getG(hoge[i+1][j]))*(double)(getG(hoge[i][j])-getG(hoge[i+1][j])); B += (double)(getB(hoge[i][j])-getB(hoge[i+1][j]))*(double)(getB(hoge[i][j])-getB(hoge[i+1][j])); } if(j) { R += (double)(getR(hoge[i][j])-getR(hoge[i][j-1]))*(double)(getR(hoge[i][j])-getR(hoge[i][j-1])); G += (double)(getG(hoge[i][j])-getG(hoge[i][j-1]))*(double)(getG(hoge[i][j])-getG(hoge[i][j-1])); B += (double)(getB(hoge[i][j])-getB(hoge[i][j-1]))*(double)(getB(hoge[i][j])-getB(hoge[i][j-1])); } if(j double)(getR(hoge[i][j])-getR(hoge[i][j+1]))*(double)(getR(hoge[i][j])-getR(hoge[i][j+1])); G += (double)(getG(hoge[i][j])-getG(hoge[i][j+1]))*(double)(getG(hoge[i][j])-getG(hoge[i][j+1])); B += (double)(getB(hoge[i][j])-getB(hoge[i][j+1]))*(double)(getB(hoge[i][j])-getB(hoge[i][j+1])); } } if( ((double)R/(double)(h*w)+(double)G/(double)(h*w)+(double)B/(double)(h*w))/3 <= 500) puts("4"); else if( ((double)R/(double)(h*w)+(double)G/(double)(h*w)+(double)B/(double)(h*w))/3 >= 5000) puts("3"); else { R=0,G=0,B=0; for(int i=0;i for(int j=0;j double)(getR(hoge[i][j]))*(double)(getR(hoge[i][j])); G += (double)(getG(hoge[i][j]))*(double)(getG(hoge[i][j])); B += (double)(getB(hoge[i][j]))*(double)(getB(hoge[i][j])); } B /= (double)(h*w); if(B>=12000) puts("1"); else puts("2"); } } }