Submission #962334

#TimeUsernameProblemLanguageResultExecution timeMemory
962334serkanrashidArt Class (IOI13_artclass)C++14
0 / 100
64 ms21000 KiB
#include "artclass.h" #include <bits/stdc++.h> using namespace std; int h,w; struct Point { int x,y; Point(){}; Point(int xi, int yi) { x = xi; y = yi; } bool is_valid() { return x>=0&&x<h&&y>=0&&y<w; } }; Point dir[4] = {{1,0},{-1,0},{0,1},{0,-1}}; int r[500][500],g[500][500],b[500][500]; int c[500][500],used[500][500]; vector<int>comp; map<int,int>mymap; vector<int>pr; void dfs(Point beg) { used[beg.x][beg.y] = 1; for(int i = 0; i < 4; i++) { Point nb; nb.x = beg.x + dir[i].x; nb.y = beg.y + dir[i].y; if(nb.is_valid() && !used[nb.x][nb.y]) dfs(nb); } } void ps(int x, int y) { for(int i=x;i<h;i++) { if(used[i][y]) break; used[i][y] = 1; for(int j=y+1;j<w;j++) { if(used[i][j]) break; used[i][j] = 1; } } pr.push_back(c[x][y]); } int col_br; int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) { h = H; w = W; int avg; int x,y,z; for(int i = 0; i < H; i++) { for(int j = 0; j < W; j++) { avg += R[i][j]+G[i][j]+B[i][j]; x += R[i][j]; y += G[i][j]; z += B[i][j]; r[i][j] = R[i][j]/10; g[i][j] = G[i][j]/10; b[i][j] = B[i][j]/10; c[i][j] = r[i][j]*10000 + g[i][j]*100 + b[i][j]; } } avg /= (H*W); for(int i = 0; i < H; i++) { for(int j = 0; j < W; j++) { if(!used[i][j]) { dfs({i,j}); comp.push_back(c[i][j]); mymap[c[i][j]]++; if(mymap[c[i][j]]==1) col_br++; } } } memset(used,0,sizeof(used)); for(int i = 0; i<H;i++) { for(int j=0;j<W;j++) { ps(i,j); } } int csz = comp.size(); int psz = pr.size(); if(col_br<=5&&abs(csz-psz)<=5) return 4; if(col_br<=7&&abs(csz-psz)<=csz) return 1; if(col_br<=120&&avg<=95) return 3; return 2; } /*int main() { int h,w; int R[500][500],G[500][500],B[500][500]; cout << style(h,w,R,G,B) << endl; return 0; }*/

Compilation message (stderr)

artclass.cpp: In function 'int style(int, int, int (*)[500], int (*)[500], int (*)[500])':
artclass.cpp:79:9: warning: 'avg' may be used uninitialized in this function [-Wmaybe-uninitialized]
   79 |     avg /= (H*W);
      |     ~~~~^~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...