제출 #724204

#제출 시각아이디문제언어결과실행 시간메모리
724204Urvuk3미술 수업 (IOI13_artclass)C++17
51 / 100
97 ms25656 KiB
#include "artclass.h" #include <bits/stdc++.h> using namespace std; #define ll long long const int INF=1e9; const ll LINF=1e18; #define fi first #define se second #define pii pair<int,int> #define mid ((l+r)/2) #define sz(a) (int((a).size())) #define all(a) a.begin(),a.end() #define endl "\n" #define pb push_back void PRINT(int x) {cerr << x;} void PRINT(ll x) {cerr << x;} void PRINT(double x) {cerr << x;} void PRINT(char x) {cerr << '\'' << x << '\'';} void PRINT(string x) {cerr << '\"' << x << '\"';} void PRINT(bool x) {cerr << (x ? "true" : "false");} template<typename T,typename V> void PRINT(pair<T,V>& x){ cerr<<"{"; PRINT(x.fi); cerr<<","; PRINT(x.se); cerr<<"}"; } template<typename T> void PRINT(T &x){ int id=0; cerr<<"{"; for(auto _i:x){ cerr<<(id++ ? "," : ""); PRINT(_i); } cerr<<"}"; } void _PRINT(){ cerr<<"]\n"; } template<typename Head,typename... Tail> void _PRINT(Head h,Tail... t){ PRINT(h); if(sizeof...(t)) cerr<<", "; _PRINT(t...); } #define Debug(x...) cerr<<"["<<#x<<"]=["; _PRINT(x) int Hg,Wg; bool visited[500][500]; int Rg[500][500],Gg[500][500],Bg[500][500]; vector<int> di,dj; int comps; bool Valid(int i,int j){ return (0<=i && i<Hg) && (0<=j && j<Wg); } void Dfs(int i,int j){ visited[i][j]=true; for(int d=0;d<4;d++){ int i1=i+di[d]; int j1=j+dj[d]; if(!Valid(i1,j1)) continue; ll dif=0; dif+=abs(Rg[i][j]-Rg[i1][j1]); dif+=abs(Gg[i][j]-Gg[i1][j1]); dif+=abs(Bg[i][j]-Bg[i1][j1]); if(!visited[i1][j1] && dif<=20){ Dfs(i1,j1); } } } bool In(int x,int l,int r){ return (l<=x && x<=r); } int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) { Hg=H,Wg=W; for(int i=0;i<500;i++){ for(int j=0;j<500;j++){ Rg[i][j]=R[i][j]; Gg[i][j]=G[i][j]; Bg[i][j]=B[i][j]; } } di={-1,0,1,0}; dj={0,1,0,-1}; for(int i=0;i<H;i++){ for(int j=0;j<W;j++){ if(!visited[i][j]){ Dfs(i,j); comps++; } } } di={-1,1}; dj={0,0}; ll Rv=0,Gv=0,Bv=0; int greens=0; int yellows=0; for(int i=0;i<Hg;i++){ for(int j=0;j<Wg;j++){ if(R[i][j]-G[i][j]>=30 && R[i][j]-B[i][j]>=30) greens++; if(R[i][j]-G[i][j]<=30) yellows++; for(int d=0;d<2;d++){ int i1=i+di[d]; int j1=j+dj[d]; if(Valid(i1,j1)){ Rv+=abs(R[i][j]-R[i1][j1]); Gv+=abs(G[i][j]-G[i1][j1]); Bv+=abs(B[i][j]-B[i1][j1]); } } } } di={0,0}; dj={-1,1}; ll Rh=0,Gh=0,Bh=0; for(int i=0;i<Hg;i++){ for(int j=0;j<Wg;j++){ for(int d=0;d<2;d++){ int i1=i+di[d]; int j1=j+dj[d]; if(Valid(i1,j1)){ Rh+=abs(R[i][j]-R[i1][j1]); Gh+=abs(G[i][j]-G[i1][j1]); Bh+=abs(B[i][j]-B[i1][j1]); } } } } di={-1,0,1,0}; dj={0,1,0,-1}; ll similar=0; ll disimilar=0; vector<ll> ret={Rv,Gv,Bv,Rh,Gh,Bh}; //Debug(greens+yellows); //Debug(comps); bool b1=true; for(int i=0;i<3;i++) b1&=In(ret[i],6,20); b1|=(comps<11503); if(b1) return 1; for(int i=0;i<sz(ret);i++) ret[i]/=(H*W); bool b4=true; for(int i=0;i<6;i++) b4&=In(ret[i],0,10); if(b4) return 4; bool b3=true; for(int i=0;i<6;i++) b3&=In(ret[i],33,100); if(b3) return 3; return 2; }

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

artclass.cpp: In function 'int style(int, int, int (*)[500], int (*)[500], int (*)[500])':
artclass.cpp:142:8: warning: unused variable 'similar' [-Wunused-variable]
  142 |     ll similar=0;
      |        ^~~~~~~
artclass.cpp:143:8: warning: unused variable 'disimilar' [-Wunused-variable]
  143 |     ll disimilar=0;
      |        ^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...