제출 #29713

#제출 시각아이디문제언어결과실행 시간메모리
29713inqr미술 수업 (IOI13_artclass)C++14
0 / 100
225 ms26952 KiB
#include "artclass.h" #include <bits/stdc++.h> #define pb push_back #define mp make_pair #define rt insert #define st first #define nd second #define ll long long using namespace std; int h,w,r[500][500],g[500][500],b[500][500]; int d[8][2]={{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}}; int d2[4][2]={{-1,0},{1,0},{0,-1},{0,1}}; int diffedge,diffsame; int dfsv[505][505]; vector <pair<int,int> > edges_dfs; vector <pair<int,int> > edges; int change(int h1,int w1,int h2,int w2){return abs(r[h1][w1]-r[h2][w2])+abs(g[h1][w1]-g[h2][w2])+abs(b[h1][w1]-b[h2][w2]);} void dfs(int hn,int wn){ if(dfsv[hn][wn]==1)return; dfsv[hn][wn]=1; //printf("\ndfs= %d %d\n",hn,wn); int isedge=0; for(int i=0;i<8;i++){ if(change(hn,wn,hn+d[i][0],wn+d[i][1])>=diffedge) isedge++; } if(isedge>=5){ edges.pb(mp(hn,wn)); edges_dfs.pb(mp(hn,wn)); } for(int i=0;i<4;i++){ int hnx=hn+d2[i][0],wnx=wn+d2[i][1]; //printf("%d %d -> %d %d\n",hn,wn,hnx,wnx); //printf("%d %d %d\n",i,d2[i][0],d2[i][1]); //printf("hn wn %d %d %d\n",r[hn][wn],g[hn][wn],b[hn][wn]); //printf("hnx wnx %d %d %d\n",r[hnx][wnx],g[hnx][wnx],b[hnx][wnx]); //printf("change hn hnx=%d\n",change(hn,wn,hnx,wnx)); //printf("dfsv hn wn =%d hnx wnx=%d\n",dfsv[hn][wn],dfsv[hnx][wnx]); if(!dfsv[hnx][wnx]){ //printf("1\n"); if(change(hn,wn,hnx,wnx)<=diffsame){ //printf("2\n"); if(0<=hnx&&hnx<h&&0<=wnx&&wnx<w){ //printf(" %d %d -> %d %d\n",hn,wn,hnx,wnx); dfs(hn+d2[i][0],wn+d2[i][1]); } } } } } int solve(){ int s1,s2,s3,s4;s1=s2=s3=s4=0; int groupcnt=0; memset(dfsv,0,sizeof(dfsv)); for(int i=0;i<h;i++){ for(int j=0;j<w;j++){ if(dfsv[i][j]==0){ edges.clear(); groupcnt++; dfs(i,j); //printf("edges = %d\n",(int)edges_dfs.size()); } } } //printf("groupcnt=%d\n",groupcnt); if(edges.size()<=500)return 1; else if(edges.size()>=3000)return 3; else return 4; } int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) { //freopen("artclass.out","w",stdout); h=H;w=W; long long gg,rr,bb; 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]; gg+=g[i][j]; bb+=b[i][j]; rr+=r[i][j]; if(gg>=bb+rr)return 2; } } diffsame=160; diffedge=320; return solve(); }

컴파일 시 표준 에러 (stderr) 메시지

artclass.cpp: In function 'int solve()':
artclass.cpp:57:6: warning: variable 's1' set but not used [-Wunused-but-set-variable]
  int s1,s2,s3,s4;s1=s2=s3=s4=0;
      ^~
artclass.cpp: In function 'int style(int, int, int (*)[500], int (*)[500], int (*)[500])':
artclass.cpp:86:6: warning: 'bb' may be used uninitialized in this function [-Wmaybe-uninitialized]
    bb+=b[i][j];
    ~~^~~~~~~~~
artclass.cpp:87:6: warning: 'rr' may be used uninitialized in this function [-Wmaybe-uninitialized]
    rr+=r[i][j];
    ~~^~~~~~~~~
artclass.cpp:85:6: warning: 'gg' may be used uninitialized in this function [-Wmaybe-uninitialized]
    gg+=g[i][j];
    ~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...