# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
8133 | gs13073 | Art Class (IOI13_artclass) | C++98 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<stdio.h>
#include<math.h>
int H,W;
double val[505][505];
double a,v,sq;
int R[500][500], G[500][500], B[500][500];
int main()
{
int i,j,k,l;
scanf("%d %d",&H,&W);
for(i=0;i<H;i++)for(j=0;j<W;j++)scanf("%d",&R[i][j]);
for(i=0;i<H;i++)for(j=0;j<W;j++)scanf("%d",&G[i][j]);
for(i=0;i<H;i++)for(j=0;j<W;j++)scanf("%d",&B[i][j]);
int A[8][2]={{1,1},{1,0},{1,-1},{-1,1},{-1,0},{-1,-1},{0,1},{0,-1}};
for(i=0;i<H;i++){
for(j=0;j<W;j++){
int cnt=0;
double sum=0,tmp=0;
int r=R[i][j];
int g=G[i][j];
int b=B[i][j];
for(k=0;k<8;k++){
i+=A[k][0];
j+=A[k][1];
if(i>=0 && i<H && j>=0 && j<W){
tmp=(R[i][j]-r)*(R[i][j]-r)
+(G[i][j]-g)*(G[i][j]-g)
+(B[i][j]-b)*(B[i][j]-b);
tmp=sqrt(tmp);
sum+=tmp;
cnt++;
}
i-=A[k][0];
j-=A[k][1];
}
val[i][j]=sum/cnt;
a+=val[i][j];
sq+=(val[i][j]*val[i][j]);
}
}
a/=(H*W);
sq/=(H*W);
double b=sq-a*a;
if(a*b < 500 )printf("4");
else if(b>500 && a>30)printf("3");
else if(b/a > 15)printf("1");
else printf("2");
return 0;
}