제출 #1035721

#제출 시각아이디문제언어결과실행 시간메모리
1035721andrei_iorgulescu미술 수업 (IOI13_artclass)C++14
36 / 100
88 ms23124 KiB
#include "artclass.h" #include <bits/stdc++.h> using namespace std; int HH,WW; int const_dif_lejer = 50; int const_dif_hard = 20; int RR[505][505],GG[505][505],BB[505][505]; bool similar(int r1, int g1, int b1, int r2, int g2, int b2, int const_dif) { if (abs(r1 - r2) > const_dif or abs(g1 - g2) > const_dif or abs(b1 - b2) > const_dif) return false; return true; } bool sim(int l1, int c1, int l2, int c2) { return similar(RR[l1][c1], GG[l1][c1], BB[l1][c1], RR[l2][c2], GG[l2][c2], BB[l2][c2], const_dif_lejer); } int dl[] = {-1,0,1,0}; int dc[] = {0,1,0,-1}; bool viz[505][505]; void dfs(int lin, int col) { viz[lin][col] = true; for (int i = 0; i < 4; i++) { int nl = lin + dl[i],nc = col + dc[i]; if (nl >= 0 and nl < HH and nc >= 0 and nc < WW and sim(lin,col,nl,nc) and !viz[nl][nc]) dfs(nl,nc); } } bool stil_4() { for (int i = 0; i < HH; i++) for (int j = 0; j < WW; j++) viz[i][j] = false; int cc = 0; for (int i = 0; i < HH; i++) for (int j = 0; j < WW; j++) if (!viz[i][j]) cc++,dfs(i,j); if (cc <= 10) return true; return false; } int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) { HH = H; WW = W; for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) RR[i][j] = R[i][j],GG[i][j] = G[i][j],BB[i][j] = B[i][j]; vector<bool> could_be(5); for (int i = 1; i <= 4; i++) could_be[i] = true; int cnt_nonculoare = 0,cnt_alb = 0,cnt_negru = 0; for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { if (similar(R[i][j],G[i][j],B[i][j],0,0,0,const_dif_lejer)) cnt_negru++; if (similar(R[i][j],G[i][j],B[i][j],255,255,255,const_dif_lejer)) cnt_alb++; } } cnt_nonculoare = cnt_alb + cnt_negru; double proc_alb = (double)cnt_alb / (double)(H * W); double proc_negru = (double)cnt_negru / (double)(H * W); double proc_nonculoare = (double)cnt_nonculoare / (double)(H * W); int sum_R = 0, sum_G = 0, sum_B = 0; for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { sum_R += R[i][j]; sum_G += G[i][j]; sum_B += B[i][j]; } } double proc_R = (double)sum_R / (double)(sum_R + sum_G + sum_B); double proc_G = (double)sum_G / (double)(sum_R + sum_G + sum_B); double proc_B = (double)sum_G / (double)(sum_R + sum_G + sum_B); int cate_dom_G = 0,cate_dom_R = 0, cate_dom_B = 0; for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { int r = R[i][j] - 20,g = G[i][j],b = B[i][j]; if (g > max(r,b) + 10) cate_dom_G++; if (r > max(g,b) + 10) cate_dom_R++; if (b > max(g,r) + 10) cate_dom_B++; } } double proc_dom_G = 0,proc_dom_R = 0,proc_dom_B = 0; int sm_dom = cate_dom_R + cate_dom_G + cate_dom_B; if (sm_dom != 0) { proc_dom_G = (double)cate_dom_G / (double)sm_dom; proc_dom_R = (double)cate_dom_R / (double)sm_dom; proc_dom_B = (double)cate_dom_B / (double)sm_dom; } //cout << setprecision(10) << fixed; //cout << proc_dom_R << ' ' << proc_dom_G << ' ' << proc_dom_B << endl; if (proc_alb >= 0.2d) return 1; if (stil_4()) return 4; if (proc_dom_G >= 0.7d) return 2; if (proc_negru >= 0.2d) return 3; return 2; }

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

artclass.cpp: In function 'int style(int, int, int (*)[500], int (*)[500], int (*)[500])':
artclass.cpp:78:12: warning: unused variable 'proc_nonculoare' [-Wunused-variable]
   78 |     double proc_nonculoare = (double)cnt_nonculoare / (double)(H * W);
      |            ^~~~~~~~~~~~~~~
artclass.cpp:89:12: warning: unused variable 'proc_R' [-Wunused-variable]
   89 |     double proc_R = (double)sum_R / (double)(sum_R + sum_G + sum_B);
      |            ^~~~~~
artclass.cpp:90:12: warning: unused variable 'proc_G' [-Wunused-variable]
   90 |     double proc_G = (double)sum_G / (double)(sum_R + sum_G + sum_B);
      |            ^~~~~~
artclass.cpp:91:12: warning: unused variable 'proc_B' [-Wunused-variable]
   91 |     double proc_B = (double)sum_G / (double)(sum_R + sum_G + sum_B);
      |            ^~~~~~
artclass.cpp:106:27: warning: variable 'proc_dom_R' set but not used [-Wunused-but-set-variable]
  106 |     double proc_dom_G = 0,proc_dom_R = 0,proc_dom_B = 0;
      |                           ^~~~~~~~~~
artclass.cpp:106:42: warning: variable 'proc_dom_B' set but not used [-Wunused-but-set-variable]
  106 |     double proc_dom_G = 0,proc_dom_R = 0,proc_dom_B = 0;
      |                                          ^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...