Submission #585049

#TimeUsernameProblemLanguageResultExecution timeMemory
585049benson1029Art Class (IOI13_artclass)C++14
100 / 100
137 ms30244 KiB
#include "artclass.h" #include <bits/stdc++.h> using namespace std; int h,w; bool vis[500][500]; int v[500][500][3]; double avg[500][500][3]; bool valid(int x, int y) { return (x>=0&&y>=0&&x<h&&y<w); } bool near(int X1, int Y1, int X2, int Y2) { return (abs(v[X1][Y1][0]-v[X2][Y2][0]) + abs(v[X1][Y1][1]-v[X2][Y2][1]) + abs(v[X1][Y1][2]-v[X2][Y2][2])) <= 40; } bool near2(int X1, int Y1, int X2, int Y2) { return (abs(v[X1][Y1][0]-v[X2][Y2][0]) + abs(v[X1][Y1][1]-v[X2][Y2][1]) + abs(v[X1][Y1][2]-v[X2][Y2][2])) <= 10; } void dfs(int x, int y) { vis[x][y] = true; for(int dx=-3; dx<=3; dx++) for(int dy=-3; dy<=3; dy++) { if(!valid(x+dx, y+dy)) continue; if(vis[x+dx][y+dy]) continue; if(near(x, y, x+dx, y+dy)) { dfs(x+dx, y+dy); } } } 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++) { v[i][j][0] = R[i][j]; v[i][j][1] = G[i][j]; v[i][j][2] = B[i][j]; } int connected_component = 0; for(int i=0; i<h; i++) for(int j=0; j<w; j++) { if(!vis[i][j]) { dfs(i, j); connected_component++; } } double r,g,b; int cntg = 0; for(int i=0; i<h; i++) for(int j=0; j<w; j++) { r += R[i][j]; g += G[i][j]; b += B[i][j]; if(G[i][j]-60 > B[i][j] && G[i][j]+10 > R[i][j]) cntg++; } if(g > r && g > b) cntg += 100000; int cntsame = 0; for(int i=0; i<h; i++) { for(int j=0; j<w; j++) { if(i>=3 && near2(i, j, i-3, j)) cntsame++; if(j>=3 && near2(i, j, i, j-3)) cntsame++; } } if(connected_component <= 50) return 4; if(connected_component>4000) return 3; if(cntsame>100000) return 1; if(cntg > 4000) return 2; return 3; }

Compilation message (stderr)

artclass.cpp: In function 'int style(int, int, int (*)[500], int (*)[500], int (*)[500])':
artclass.cpp:56:14: warning: 'g' may be used uninitialized in this function [-Wmaybe-uninitialized]
   56 |     if(g > r && g > b) cntg += 100000;
      |        ~~~~~~^~~~~~~~
artclass.cpp:56:14: warning: 'b' may be used uninitialized in this function [-Wmaybe-uninitialized]
artclass.cpp:56:5: warning: 'r' may be used uninitialized in this function [-Wmaybe-uninitialized]
   56 |     if(g > r && g > b) cntg += 100000;
      |     ^~
#Verdict Execution timeMemoryGrader output
Fetching results...