Submission #29766

#TimeUsernameProblemLanguageResultExecution timeMemory
29766NikeforArt Class (IOI13_artclass)C++98
0 / 100
166 ms37716 KiB
#include "artclass.h" #include<cmath> int ctr = 0; bool visit[501][501]; int h, w; int r[500][500], g[500][500], b[500][500]; bool match(int i1, int j1, int i2, int j2) { if(std::abs(r[i1][j1]-r[i2][j2]) > 50 ) return false; if(std::abs(g[i1][j1]-g[i2][j2]) > 50 ) return false; if(std::abs(b[i1][j1]-b[i2][j2]) > 50 ) return false; return true; } void DFS(int i, int j) { visit[i][j] = true; if(i!=0 and match(i, j, i-1, j) and !visit[i-1][j]) DFS(i-1,j); if(i!=h-1 and match(i, j, i+1, j) and !visit[i+1][j]) DFS(i+1, j); if(j!=0 and match(i, j, i, j-1) and !visit[i][j-1]) DFS(i,j-1); if(j!=w-1 and match(i, j, i, j+1) and !visit[i][j+1]) DFS(i, j+1); } int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) { h = H, w = W; for(int i=0; i<h; i++) for(int j=0; j<500; j++) { r[i][j] = R[i][j]; g[i][j] = G[i][j]; b[i][j] = B[i][j]; } for(int i=0; i<500; i++) for(int j=0; j<500; j++) { if(!visit[i][j]) { ctr++; DFS(i,j); } } if(ctr<20) return 4; //if(ctr<10) return 2; //if(ctr<20) return 1; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...