Submission #126178

#TimeUsernameProblemLanguageResultExecution timeMemory
126178nxteruArt Class (IOI13_artclass)C++14
0 / 100
155 ms30840 KiB
#include "artclass.h" #include <bits/stdc++.h> using namespace std; #define D 20 #define PB push_back int h,w,r[505][505],g[505][505],b[505][505],s,t[10005],sz; vector<int>q[250005]; bool vis[250005]; void dfs(int v){ vis[v]=true; s++; for(int i=0;i<q[v].size();i++){ if(!vis[q[v][i]]){ dfs(q[v][i]); } } } int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) { h=H,w=W; //cout<<h<<' '<<w<<endl; 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]; } } //cout<<"ok\n"; for(int i=0;i<h;i++){ for(int j=0;j<w;j++){ if(j+1<w&&abs(r[i][j]-r[i][j+1])<D&&abs(g[i][j]-g[i][j+1])<D&&abs(b[i][j]-b[i][j+1])<D){ q[i*w+j].PB(i*w+j+1); q[i*w+j+1].PB(i*w+j); } if(i+1<h&&abs(r[i][j]-r[i+1][j])<D&&abs(g[i][j]-g[i+1][j])<D&&abs(b[i][j]-b[i+1][j])<D){ q[i*w+j].PB((i+1)*w+j); q[(i+1)*w+j].PB(i*w+j); } vis[i*w+j]=false; } } //cout<<"ok\n"; for(int i=0;i<h*w;i++){ if(!vis[i]){ s=0; dfs(i); if(s<10000)t[s/100]++; sz++; } } //cout<<sz<<endl; for(int i=0;i<100;i++)cout<<t[i]<<' '; //cout<<endl; if(sz<100)return 4; if(sz<10000)return 1; if(sz<30000)return 2; return 3; }

Compilation message (stderr)

artclass.cpp: In function 'void dfs(int)':
artclass.cpp:12:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<q[v].size();i++){
              ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...