Submission #94195

#TimeUsernameProblemLanguageResultExecution timeMemory
94195fjzzq2002Art Class (IOI13_artclass)C++14
93 / 100
458 ms12540 KiB
#include "artclass.h" #include <bits/stdc++.h> using namespace std; typedef double ld; struct pnt { int x,y,z; }; pnt operator + (pnt a,pnt b) {return pnt{a.x+b.x,a.y+b.y,a.z+b.z};} ld sqr(ld x) {return x*x;} ld dis(pnt a,pnt b) {return sqrt(sqr(a.x-b.x)+sqr(a.y-b.y)+sqr(a.z-b.z));} pnt u[500][500],p[100][100],t[23333]; int tn=0; int ff[999999]; int gf(int x) {return (~ff[x])?ff[x]=gf(ff[x]):x;} void uni(int a,int b) { a=gf(a),b=gf(b); if(a!=b) ff[a]=b; } 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) u[i][j]=pnt{R[i][j],G[i][j],B[i][j]}; int HH=H/5,WW=W/5; tn=0; for(int i=0;i<HH;++i) for(int j=0;j<WW;++j) { for(int x=0;x<5;++x) for(int y=0;y<5;++y) p[i][j]=p[i][j]+u[i*5+x][j*5+y]; p[i][j].x/=25, p[i][j].y/=25, p[i][j].z/=25; } ld V0,V1,V2,V3,V4,V5,V6,V7,V8,V9,V10,V11; { int s0=0; ld s1=0; for(int i=0;i<HH;++i) for(int j=0;j<WW;++j) s1+=p[i][j].x,++s0; V0=s1/s0; //S2: <=120 } { int s0=0; ld s1=0; for(int i=0;i<HH;++i) for(int j=0;j+1<WW;++j) ++s0,s1+=dis(p[i][j],p[i][j+1]); for(int i=0;i+1<HH;++i) for(int j=0;j<WW;++j) ++s0,s1+=dis(p[i][j],p[i+1][j]); V1=s1/s0; } { int cn=0; pnt g{0,0,0}; for(int i=0;i<HH;++i) for(int j=0;j<WW;++j) g=g+p[i][j],++cn; g.x/=cn,g.y/=cn,g.z/=cn; int s0=0; ld s1=0; for(int i=0;i<HH;++i) for(int j=0;j<WW;++j) s1+=dis(p[i][j],g),++s0; V2=s1/s0; } { int s0=0; ld s1=0; for(int i=0;i<HH;++i) for(int j=0;j<WW;++j) { for(int x=0;x<5;++x) for(int y=0;y<5;++y) s1+=dis(u[i*5+x][j*5+y],p[i][j]),++s0; } V3=s1/s0; } for(int i=0;i<HH;++i) for(int j=0;j<WW;++j) if(rand()%3) t[++tn]=p[i][j]; { int s0=0; ld s1=0; for(int i=1;i<=tn;++i) for(int j=i+1;j<=tn;++j) s1+=dis(t[i],t[j]),++s0; V4=s1/s0; } { int s0=0; ld s1=0; for(int i=1;i<=tn;++i) for(int j=i+1;j<=tn;++j) s1+=dis(t[i],t[j])<=10,++s0; V5=s1/s0; } { int s0=0; ld s1=0; for(int i=0;i<HH;++i) for(int j=0;j<WW;++j) for(int k=j+1;k<WW&&k<=j+5;++k) s1+=sqr(dis(p[i][j],p[i][k])),++s0; V6=s1/s0; } { int s0=0; ld s1=0; for(int i=0;i<WW;++i) for(int j=0;j<HH;++j) for(int k=j+1;k<HH&&k<=j+5;++k) s1+=sqr(dis(p[j][i],p[k][i])),++s0; V7=s1/s0; } { int s0=0; ld s1=0; for(int i=0;i<HH;++i) for(int j=0;j<WW;++j) for(int t=i;t<=i+4&&t<HH;++t) for(int r=j;r<=j+4&&r<=HH;++r) ++s0,s1+=pow(dis(p[i][j],p[t][r]),3); V8=s1/s0; } { int s0=0; ld s1=0; for(int i=1;i<=tn;++i) for(int j=i+1;j<=tn;++j) if(dis(t[i],t[j])<=40) s1+=dis(t[i],t[j]),++s0; V9=s1/s0; } { memset(ff,-1,sizeof ff); for(int i=0;i<H;++i) for(int j=0;j+1<W;++j) if(dis(u[i][j],u[i][j+1])<30) uni(i*W+j,i*W+j+1); for(int i=0;i+1<H;++i) for(int j=0;j<W;++j) if(dis(u[i+1][j],u[i][j])<30) uni((i+1)*W+j,i*W+j); int s0=0; ld s1=0; for(int i=0;i<H;++i) for(int j=0;j<W;++j,++s0) if(gf(i*W+j)==i*W+j) ++s1; V10=s1; } { memset(ff,-1,sizeof ff); for(int i=0;i<H;++i) for(int j=0;j+1<W;++j) if(dis(u[i][j],u[i][j+1])<90) uni(i*W+j,i*W+j+1); for(int i=0;i+1<H;++i) for(int j=0;j<W;++j) if(dis(u[i+1][j],u[i][j])<90) uni((i+1)*W+j,i*W+j); int s0=0; ld s1=0; for(int i=0;i<H;++i) for(int j=0;j<W;++j,++s0) if(gf(i*W+j)==i*W+j) ++s1; V11=s1/ld(H*W); } //cerr<<V0<<","; if(V10<50) return 4; if(V11>0.003) return 3; if(V0>138) return 1; return 2; if(V0<=140&&V8<=2e5) return 2+rand()%2*2; if(V0<=140) return 2; if(V8<=2e5) return 4; return 1; }

Compilation message (stderr)

artclass.cpp: In function 'int style(int, int, int (*)[500], int (*)[500], int (*)[500])':
artclass.cpp:37:8: warning: variable 'V1' set but not used [-Wunused-but-set-variable]
  ld V0,V1,V2,V3,V4,V5,V6,V7,V8,V9,V10,V11;
        ^~
artclass.cpp:37:11: warning: variable 'V2' set but not used [-Wunused-but-set-variable]
  ld V0,V1,V2,V3,V4,V5,V6,V7,V8,V9,V10,V11;
           ^~
artclass.cpp:37:14: warning: variable 'V3' set but not used [-Wunused-but-set-variable]
  ld V0,V1,V2,V3,V4,V5,V6,V7,V8,V9,V10,V11;
              ^~
artclass.cpp:37:17: warning: variable 'V4' set but not used [-Wunused-but-set-variable]
  ld V0,V1,V2,V3,V4,V5,V6,V7,V8,V9,V10,V11;
                 ^~
artclass.cpp:37:20: warning: variable 'V5' set but not used [-Wunused-but-set-variable]
  ld V0,V1,V2,V3,V4,V5,V6,V7,V8,V9,V10,V11;
                    ^~
artclass.cpp:37:23: warning: variable 'V6' set but not used [-Wunused-but-set-variable]
  ld V0,V1,V2,V3,V4,V5,V6,V7,V8,V9,V10,V11;
                       ^~
artclass.cpp:37:26: warning: variable 'V7' set but not used [-Wunused-but-set-variable]
  ld V0,V1,V2,V3,V4,V5,V6,V7,V8,V9,V10,V11;
                          ^~
artclass.cpp:37:32: warning: variable 'V9' set but not used [-Wunused-but-set-variable]
  ld V0,V1,V2,V3,V4,V5,V6,V7,V8,V9,V10,V11;
                                ^~
#Verdict Execution timeMemoryGrader output
Fetching results...