제출 #1035647

#제출 시각아이디문제언어결과실행 시간메모리
1035647andrei_iorgulescu미술 수업 (IOI13_artclass)C++14
21 / 100
42 ms6224 KiB
#include "artclass.h" #include <bits/stdc++.h> using namespace std; int const_dif_lejer = 50; int const_dif_hard = 20; 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; } int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) { 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.25d) return 1; if (proc_dom_G >= 0.7d) return 2; if (proc_dom_R >= 0.9d) return 4; if (proc_dom_B <= 0.1d) return 2; return 3; }

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

artclass.cpp: In function 'int style(int, int, int (*)[500], int (*)[500], int (*)[500])':
artclass.cpp:34:12: warning: unused variable 'proc_negru' [-Wunused-variable]
   34 |     double proc_negru = (double)cnt_negru / (double)(H * W);
      |            ^~~~~~~~~~
artclass.cpp:35:12: warning: unused variable 'proc_nonculoare' [-Wunused-variable]
   35 |     double proc_nonculoare = (double)cnt_nonculoare / (double)(H * W);
      |            ^~~~~~~~~~~~~~~
artclass.cpp:46:12: warning: unused variable 'proc_R' [-Wunused-variable]
   46 |     double proc_R = (double)sum_R / (double)(sum_R + sum_G + sum_B);
      |            ^~~~~~
artclass.cpp:47:12: warning: unused variable 'proc_G' [-Wunused-variable]
   47 |     double proc_G = (double)sum_G / (double)(sum_R + sum_G + sum_B);
      |            ^~~~~~
artclass.cpp:48:12: warning: unused variable 'proc_B' [-Wunused-variable]
   48 |     double proc_B = (double)sum_G / (double)(sum_R + sum_G + sum_B);
      |            ^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...