Submission #1303561

#TimeUsernameProblemLanguageResultExecution timeMemory
1303561activedeltorre미술 수업 (IOI13_artclass)C++20
61 / 100
68 ms38944 KiB
#include "artclass.h" #include <iostream> #include <iomanip> #include <math.h> using namespace std; pair<int,int> sef[505][505][10]; int sz[505][505][10]; int trd=9; int v[]= {1,2,3,5,10,20,30,35,50}; pair<int,int> find(pair<int,int> a,int tr) { if(sef[a.first][a.second][tr]==a) { return a; } return sef[a.first][a.second][tr]=find(sef[a.first][a.second][tr],tr); } void merge(pair<int,int>a,pair<int,int>b,int tr) { a=find(a,tr); b=find(b,tr); if(a==b) { return; } sef[b.first][b.second][tr]=a; sz[a.first][a.first][tr]+=sz[b.first][b.first][tr]; } double r1[505][505]; double g1[505][505]; double b1[505][505]; long long tot=0,cnt=0,tot2=0,tot3=0; long long tot0=0,cnt0=0,tot20=0,tot30=0; int fre[205]; void trysame(int a,int b,int x,int y) { int val=round(abs(r1[a][b]-r1[x][y])+abs(b1[a][b]-b1[x][y])+abs(g1[a][b]-g1[x][y])); tot=tot+val; tot2=tot2+val*val; tot3=tot3+val*val*val; cnt++; fre[val]++; if(val>=2) { tot0=tot0+val; tot20=tot20+val*val; tot30=tot30+val*val*val; cnt0++; } } 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++) { for(int z=0; z<trd; z++) { sef[i][j][z]=make_pair(i,j); sz[i][j][z]=1; } } } for(int i=0; i<H; i++) { for(int j=0; j<W; j++) { int sum=R[i][j]+G[i][j]+B[i][j]+1; r1[i][j]=R[i][j]*100.0/sum; g1[i][j]=G[i][j]*100.0/sum; b1[i][j]=B[i][j]*100.0/sum; if(i>=1) { trysame(i,j,i-1,j); } if(j>=1) { trysame(i,j,i,j-1); } } } /* for(int z=0; z<trd; z++) { int comps=0; for(int i=0; i<H; i++) { for(int j=0; j<W; j++) { if(sef[i][j][z].first==i && sef[i][j][z].second==j) { comps++; } } } cout<<z<<" "<<v[z]<<"% "<<comps<<'\n'; } */ double spar=0; int pos; for(int i=0;i<=100;i++) { spar=spar+(double)fre[i]/cnt; if(spar>=0.9) { pos=i; break; } } //cout<<pos<<'\n'; if(cnt0==0) { cnt0=1; } if(cnt==0) { cnt=1; } if(fre[0]*100.0/cnt>=20) { ///1 foarte probabil sau poate 4 if(tot0/cnt0>=4.5) { return 1; } return 4; } if((double)tot/cnt<=2.0) { return 4; } if(pos<=6 || pos>=20 || v[0]+v[3]<=v[1]) { return 3; } return 2; /* */ }
#Verdict Execution timeMemoryGrader output
Fetching results...