# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
56514 | hamzqq9 | Art Class (IOI13_artclass) | C++14 | 137 ms | 6640 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 "artclass.h"
#include<bits/stdc++.h>
using namespace std;
double TYPE[4]={0.000177408580,
0.000013260208};
int R[505][505],G[505][505],B[505][505];
double TotD;
int total;
int w[4][2]={1,0,0,1,-1,0,0,-1};
double sq(int a,int b) {
if(abs(a-b)<=100) return 0;
return abs(1.0*(a-b)*(a-b)*(a-b));
}
double get(int x,int y,int a,int b) {
double DR=sq(R[x][y],R[a][b]);
double DG=sq(G[x][y],G[a][b]);
double DB=sq(B[x][y],B[a][b]);
return (DR+DG+DB)/3.0;
}
int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) {
for(int i=0;i<H;i++) {
for(int j=0;j<W;j++) {
::R[i][j]=R[i][j];
::G[i][j]=G[i][j];
::B[i][j]=B[i][j];
}
}
for(int i=0;i<H;i++) {
for(int j=0;j<W;j++) {
for(int way=0;way<4;way++) {
int tor=i+w[way][0];
int toc=j+w[way][1];
if(tor>=0 && tor<H && toc>=0 && toc<W) {
total++;
TotD+=get(i,j,tor,toc);
}
}
}
}
double cur=1.0*TotD/(1.0*total*total);
double mnD=1000000000;
int whc=-1;
for(int i=0;i<2;i++) {
if(abs(cur-TYPE[i])<mnD) {
mnD=cur-TYPE[i];
whc=i;
}
}
return whc+1;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |