# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
489219 | cfalas | Art Class (IOI13_artclass) | C++17 | 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<bits/stdc++.h>
using namespace std;
//#include "artclass.h"
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
#define F first
#define S second
int getR(int RGB) { return (RGB >> 16) & 0xFF; }
int getG(int RGB) { return (RGB >> 8) & 0xFF; }
int getB(int RGB) { return RGB & 0xFF; }
int style(int h, int w, int r[500][500], int g[500][500], int b[500][500]) {
int blackcount=0;
int wcount=0;
int gcount=0;
double stdb,stdr,stdg;
double totb=0,totg=0,totr=0;
double sfrr=0,sfgg=0,sfbb=0;
double pix = h*w;
double dev=0;
double devv=0, dcnt=0;
for(int i=0;i<h;i++){
for(int j=0;j<w;j++){
if(r[i][j]+b[i][j]+g[i][j]<=25) blackcount++;
else if(r[i][j]+b[i][j]+g[i][j]>=675) wcount++;
if(g[i][j]>=100 && r[i][j]+b[i][j]<=150) gcount++;
totb+=b[i][j];
sfbb+=b[i][j]*b[i][j];
totr+=r[i][j];
sfrr+=r[i][j]*r[i][j];
if(i!=0) dev+=abs(r[i][j]-r[i-1][j]), dcnt++, devv+=(r[i][j]-r[i-1][j])*(r[i][j]-r[i-1][j]);
if(j!=0) dev+=abs(r[i][j]-r[i][j-1]), dcnt++, devv+=(r[i][j]-r[i][j-1])*(r[i][j]-r[i][j-1]);
if(i!=h-1) dev+=abs(r[i][j]-r[i+1][j]), dcnt++, devv+=(r[i][j]-r[i+1][j])*(r[i][j]-r[i+1][j]);
if(j!=w-1) dev+=abs(r[i][j]-r[i][j+1]), dcnt++, devv+=(r[i][j]-r[i][j+1])*(r[i][j]-r[i][j+1]);
}
}
stdb = sqrt(sfbb/pix - (totb/pix)*(totb/pix));
stdr = sqrt(sfrr/pix - (totr/pix)*(totr/pix));
double devstd = sqrt(devv/dcnt - (dev/dcnt)*(dev/dcnt));
//cout<<gcount/((double)h*w)<<endl;
//if(wcount!=0) cout<<(double)blackcount/wcount<<endl;
//cout<<devstd<<endl;
if(devstd<6) return 4;
if(devstd>23) return 3;
if(gcount>0.02*h*w) return 2;
if(wcount>0.03*((double)h*w) || blackcount>0.01*(h*w)) return 1;// ||(wcount!=0 && (double)blackcount/wcount<300)) return 1;
if(devstd>17.5) return 3;
return 2;
}
/*
int main(){
int t;
cin>>t;
while(t--){
int n,m;
cin>>n>>m;
int r[500][500];
int g[500][500];
int b[500][500];
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
int a;
cin>>a;
r[i][j] = getR(a);
g[i][j] = getG(a);
b[i][j] = getB(a);
}
}
cout<<style(n,m,r,g,b)<<endl;
}
}
*/