Submission #97533

#TimeUsernameProblemLanguageResultExecution timeMemory
97533tincamateiArt Class (IOI13_artclass)C++14
91 / 100
125 ms22008 KiB
#include "artclass.h" #include <bits/stdc++.h> using namespace std; const int SAMECOLOR = 60; int H, W, R[500][500], G[500][500], B[500][500]; bool viz[500][500]; bool pallette[256][256][256]; int comp, ncolors, averageGreen = 0; int neoplastic() { return -abs(comp - 100); } int impressionist() { return -abs(comp - 500); } int expressionist() { return -abs(comp - 7000); } int colourfield() { return -abs(comp - 5); } int dl[] = {0, 1, 0, -1}; int dc[] = {1, 0,-1, 0}; void dfs(int l, int c) { viz[l][c] = true; for(int i = 0; i < 4; ++i) { int ln = l + dl[i]; int cn = c + dc[i]; if(0 <= ln && ln < H && 0 <= cn && cn < W && !viz[ln][cn] && abs(R[l][c] - R[ln][cn]) + abs(G[l][c] - G[ln][cn]) + abs(B[l][c] - B[ln][cn]) <= SAMECOLOR) { dfs(ln, cn); } } } void getData() { for(int i = 0; i < H; ++i) for(int j = 0; j < W; ++j) { if(!viz[i][j]) { dfs(i, j); comp++; } if(!pallette[R[i][j] / SAMECOLOR][G[i][j] / SAMECOLOR][B[i][j] / SAMECOLOR]) { pallette[R[i][j] / SAMECOLOR][G[i][j] / SAMECOLOR][B[i][j] / SAMECOLOR] = true; ncolors++; } if(G[i][j] - R[i][j] >= 10 && G[i][j] - B[i][j] >= 80) ++averageGreen; //averageGreen = averageGreen + G[i][j] + R[i][j] + B[i][j]; } // averageGreen /= H * W; } 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 < W; ++j) { R[i][j] = _R[i][j]; G[i][j] = _G[i][j]; B[i][j] = _B[i][j]; } getData(); //printf("NR COMP %d\n", comp); //printf("NCOLORS %d\n", ncolors); //printf("Green: %d\n", averageGreen); int rez = 0; if(comp <= 20) rez = 4; else if(comp >= 15000) rez = 3; else { if(averageGreen >= 5) rez = 2; else rez = 1; } return rez; }
#Verdict Execution timeMemoryGrader output
Fetching results...