| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 235888 | cfalas | Art Class (IOI13_artclass) | C++14 | 82 ms | 4600 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 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]<=50) blackcount++;
else if(r[i][j]+b[i][j]+g[i][j]>=700) wcount++;
if(g[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;
//cout<<blackcount<<endl;
//cout<<devstd<<endl;
if(devstd<8) return 4;
if(devstd>20) return 3;
if(wcount>0.07*h*w) return 1;
if(gcount>0.11*h*w) return 2;
return 3;
/*ios::sync_with_stdio(false);
double tot = 0;
double totr=0, totg=0, totb=0;
set<iii> colors;
set<iii> allcolors;
double dr=0, dg=0, db=0;
double light = 0, dark = 0;
map<int, int> colfreq;
ofstream fout("changed.ppm");
fout<<"P3\n"<<w<<" "<<h<<endl<<1<<endl;
int rn[w/20+10][h/20+10];
int gn[w/20+10][h/20+10];
int bn[w/20+10][h/20+10];
int cn[w/20+10][h/20+10];
for(int i=0;i<h/20;i++){
for(int j=0;j<w/20;j++){
rn[j][i] = 0;
gn[j][i] = 0;
bn[j][i] = 0;
cn[j][i] = 1;
}
}
for(int i=3;i<h;i++){
for(int j=0;j<w;j++){
tot+=r[i][j]+g[i][j]+b[i][j];
totr+=r[i][j];
totg+=g[i][j];
totb+=b[i][j];
colors.insert(iii(r[i][j]/128, ii(g[i][j]/128, b[i][j]/128)));
allcolors.insert(iii(r[i][j], ii(g[i][j], b[i][j])));
colfreq[((r[i][j]*0.3) + (g[i][j]*0.59) + (b[i][j]*0.11))]++;
if(r[i][j]>g[i][j] && r[i][j]>b[i][j]) dr++;
if(g[i][j]>b[i][j] && g[i][j]>r[i][j]) dg++;
if(b[i][j]>r[i][j] && b[i][j]>g[i][j]) db++;
if(r[i][j] + g[i][j] + b[i][j] < 50) dark++;
else if(r[i][j] + g[i][j] + b[i][j] > 300) light++;
fout<<r[i][j]/128<<" "<<g[i][j]/128<<" "<<b[i][j]/128<<endl;
rn[j/20][i/20]+=r[i][j];
gn[j/20][i/20]+=g[i][j];
bn[j/20][i/20]+=b[i][j];
cn[j/20][i/20]++;
}
}
fout.close();
fout.clear();
fout.open("changed2.ppm");
fout<<"P3\n"<<w/20<<" "<<h/20<<endl<<255<<endl;
for(int i=0;i<h/20;i++){
for(int j=0;j<w/20;j++){
fout<<rn[j][i]/cn[j][i]<<" "<<gn[j][i]/cn[j][i]<<" "<<bn[j][i]/cn[j][i]<<endl;
}
}
fout.close();
fout.clear();
fout.open("redhist.txt");
for(int i=0;i<64;i++){
for(int j=0;j<(colfreq[4*i] + colfreq[4*i+1] + colfreq[4*i+2] + colfreq[4*i+3])/360;j++) fout<<"*";
fout<<endl;
}
cout<<totr/(tot)<<" "<<totg/(tot)<<" "<<totb/(tot)<<endl;
cout<<colors.size()<<endl;
cout<<dr/(w*h)<<" "<<dg/(w*h)<<" "<<db/(w*h)<<endl;
cout<<light/(w*h)<<" "<<dark/(w*h)<<endl;
cout<<allcolors.size()<<endl;
vector<pair<int, iii> > v;
/.*for(map<iii,int>::iterator it = colfreq.begin();it!=colfreq.end();it++){
v.push_back(make_pair((*it).S, (*it).F));
}
sort(v.begin(), v.end());
double totcommoncolors = 0;
for(int i=v.size()-1;i>=v.size()-10;i--){
totcommoncolors+=v[i].F;
}
cout<<totcommoncolors/(w*h)<<endl;*./
if(totr/tot<0.5 && dr+dg>db*8 && totr+totg > 3*totb && colors.size()>=5) return 2;
if(totr/tot>0.5 && colors.size()<=7 /.*|| light==0 || dark==0*./) return 4;
if(colors.size()<=3) return 4;
//if(totcommoncolors/(w*h)>0.5) return 1;
if(dark+light*2 > w*h && allcolors.size()>30000 && colors.size()>=6) return 3;
//if(totg > totb && totb<totr) return 2;
return 1;*/
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
