제출 #7594

#제출 시각아이디문제언어결과실행 시간메모리
7594Namnamseo미술 수업 (IOI13_artclass)C++98
100 / 100
150 ms6568 KiB
#include "artclass.h" #define BSIZE 256 #include <algorithm> //#include <cstdio> #include <cmath> double r1=31; double r2=1; double rg=30000; double r3=700000; double r4=0.11; long long sqr(long long x) { return x*x;} int colorcnt[BSIZE]; int allcnt; //extern int image_type, image_num; int dx[8] = {-1,-1,-1,0,0,1,1,1}; int dy[8] = {-1,0,1,-1,1,-1,0,1}; int R[500][500]; int G[500][500]; int B[500][500]; int rcount; int gcount; int bcount; int diff(int ax,int ay, int bx,int by){ return (sqr(R[ax][ay]-R[bx][by])+ sqr(G[ax][ay]-G[bx][by])+ sqr(B[ax][ay]-B[bx][by]))/3/256/(256/BSIZE)/8; } double square(double x) { return x*x; } double foursquare(double x) { return square(square(x)); } double abs(double x) { return (x>0)?x:-x; } double check1(){ double ret = 0; int i; if(1.0*colorcnt[0]/allcnt <= 0.4) { //printf("skip "); return 0; } double sample[10]={0.9019166465,0.0118866004, 0.0086173976,0.0141395687, 0.0047904047,0.0037785316, 0.0048340199,0.0027482433, 0.0022108069,0.0022844681}; for(i=0;i<10;i++){ ret += foursquare(((1.0*colorcnt[i]/allcnt)-sample[i])); } ret = 1/ret; ret *= r1; //printf("%15lf ",ret); return ret; } double check2(){ double ret = 0; int i; if(1.0*colorcnt[0]/allcnt <= 0.4) { //printf("skip "); return 0; } double sample[10]={ 0.8484479226,0.0524667046,0.0232874217,0.0135344337,0.0085207740, 0.0057063176,0.0040614684,0.0030028458,0.0022692089,0.0016602163}; for(i=0;i<10;i++){ ret += foursquare(((1.0*colorcnt[i]/allcnt)-sample[i])); } ret = 1/ret; if(bcount >= 60000 && (1.0*bcount/(1+rcount))>=1.7 && (1.0*bcount/(1+gcount))>=1.7) { //printf("#"); ret *= rg; } ret *= r2; //printf("%15lf ",ret); return ret; } double check3() { if(1.0*colorcnt[0]/allcnt > 0.6) { //printf("skip "); return 0; } double ret = 0; int i; double sample[10]={ 0.3627259093,0.3640176228,0.1051308586,0.1001394826, 0.0586884139,0.0507251594,0.0348496438,0.1098590176, 0.0257210349,0.0225976753}; for(i=0;i<10;i++){ ret += foursquare((1.0*colorcnt[i]/allcnt)-sample[i]); } ret = 1/ret; ret *= r3; //printf("%15lf ",ret); return ret; } double check4() { double ret = 0; int i; double sample[10] = {1,0.0000000780,0.0000005723,0.0000009647, 0.0000000030,0.0000000031,0.0000000828,0.0000000121, 0.0000000087,0.0000000015}; for(i=0;i<10;i++){ ret += 0.8*foursquare((1.0*colorcnt[i]/allcnt)-sample[i]); } ret = 1/ret; ret *= r4; //printf("%15lf\n",ret); return ret; } int style(int H, int W, int _R[500][500], int _G[500][500], int _B[500][500]) { int i,j,dir; int nx,ny; allcnt=0; rcount=0; gcount=0; bcount=0; for(i=0;i<H;i++) for(j=0;j<W;j++) { R[i][j]=_R[i][j]; G[i][j]=_G[i][j]; B[i][j]=_B[i][j]; if(7<=R[i][j] && R[i][j]<=50) rcount++; if(7<=G[i][j] && G[i][j]<=50) gcount++; if(7<=B[i][j] && B[i][j]<=50) bcount++; } //printf("%lf %lf\n",1.0*bcount/(1+rcount),1.0*bcount/(1+gcount)); for(i=0;i<BSIZE;i++) colorcnt[i]=0; int tmp; for(i=0;i<H;i++){ for(j=0;j<W;j++){ tmp=0; for(dir=0; dir<8; dir++){ nx = i+dx[dir]; ny = j+dy[dir]; if(nx>=0 && ny>=0 && nx<H && ny<W){ tmp+=diff(i,j,nx,ny); } } colorcnt[tmp]++; allcnt++; } } std::pair<double,int> expect[4]; for(i=0;i<4;i++){ expect[i].second = i; } expect[0].first=check1(); expect[1].first=check2(); expect[2].first=check3(); expect[3].first=check4(); std::sort(expect,expect+4); return expect[3].second+1; }
#Verdict Execution timeMemoryGrader output
Fetching results...