Submission #29607

#TimeUsernameProblemLanguageResultExecution timeMemory
29607dereotuArt Class (IOI13_artclass)C++14
0 / 100
193 ms22984 KiB
#include "artclass.h" #include <bits/stdc++.h> #define pii pair<int,int> #define mp make_pair #define pb push_back #define st first #define nd second #define forr(i,A,B) for(int i=A;i<B;++i) #define space ' ' #define endl '\n' #define LL long long using namespace std; int vis[500][500]; int dr[]={1,0,0,-1}; int dl[]={0,1,-1,0}; int green,cnt,advcnt; int g[500][500],r[500][500],b[500][500]; int h,w; void type2(int x,int y){ if(vis[x][y]) return; if(g[x][y]>100 and r[x][y]<100 and b[x][y]<100) green++; vis[x][y]=1; forr(i,0,4){ int nx=x+dr[i]; int ny=y+dl[i]; if(nx>=0 and nx<h and ny>=0 and ny<w and !vis[x+dr[i]][y+dl[i]]){ type2(x+dr[i],y+dl[i]); } } } void floodfill(int x,int y){ if(vis[x][y]) return; vis[x][y]=1; forr(i,0,4){ int nx=x+dr[i]; int ny=y+dl[i]; if(nx>=0 and nx<h and ny>=0 and ny<w and !vis[x+dr[i]][y+dl[i]]){ if(g[x+dr[i]][y+dl[i]]<=50 and r[x+dr[i]][y+dl[i]]<=50 and b[x+dr[i]][y+dl[i]]<=50) continue; floodfill(x+dr[i],y+dl[i]); } } } void advancedflood(int x,int y){ if(vis[x][y]) return; vis[x][y]=1; forr(i,0,4){ int nx=x+dr[i]; int ny=y+dl[i]; if(nx>=0 and nx<h and ny>=0 and ny<w and !vis[x+dr[i]][y+dl[i]]){ if(g[x][y]-g[x+dr[i]][y+dl[i]]>=50 or r[x][y]-r[x+dr[i]][y+dl[i]]>=50 or b[x][y]-b[x+dr[i]][y+dl[i]]>=50) continue; advancedflood(x+dr[i],y+dl[i]); } } } int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) { type2(0,0); forr(i,0,500) forr(j,0,500){ r[i][j]=R[i][j]; b[i][j]=B[i][j]; g[i][j]=G[i][j]; } h=H; w=W; if(green>=H*W*0.7) return 2; forr(i,0,500){ forr(j,0,500){ if(!vis[i][j]){ ++cnt; floodfill(i,j); } } } memset(vis,0,sizeof vis); forr(i,0,500){ forr(j,0,500){ if(!vis[i][j]){ ++advcnt; advancedflood(i,j); } } } if(cnt>=15) return 1; if(advcnt<=5) return 4; else return 3; }
#Verdict Execution timeMemoryGrader output
Fetching results...