제출 #369337

#제출 시각아이디문제언어결과실행 시간메모리
369337kostia244미술 수업 (IOI13_artclass)C++17
87 / 100
114 ms17772 KiB
#include "artclass.h" #include<bits/stdc++.h> using namespace std; using ld = long double; const int maxn = 500; using vec = array<ld, 3>; const vec green = {0, 255, 0}; const vec white = {255, 255, 255}; ld dif(vec a, vec b) { ld t = 0; for(int i = 0; i < 3; i++) t += (a[i]-b[i])*(a[i]-b[i]); return sqrt(t); } int n, m; vec img[maxn][maxn]; ld compare(vec col) { ld sum = 0; for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) sum += dif(img[i][j], col); return sum / (n*m); } ld sharpness() { ld sum = 0; for(int i = 0; i+1 < n; i++) for(int j = 0; j < m; j++) sum += dif(img[i][j], img[i+1][j]); for(int i = 0; i < n; i++) for(int j = 0; j+1 < m; j++) sum += dif(img[i][j], img[i][j+1]); sum /= n*(m-1) + (n-1)*m; return sum; } int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) { n = H, m = W; for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) { img[i][j] = {R[i][j],G[i][j],B[i][j]}; } ld f = sharpness(); ld g = compare(white); ld h = compare(green); #define B aaa const int A = 10; const int B = 5; const int C = 2; vec r = {A*f, B*g, C*h}; pair<ld, int> ans = {1<<30, 0}; vector<vec> a; a.push_back({A*11.171448888888888, B*163.45119999999997, C*294.5782222222222});//{10, 160, 290}); a.push_back({A*19.13388888888889, B*292.3247777777778, C*217.07022222222224});//{17, 280, 210}); a.push_back({A*50.98616666666666, B*228.85688888888888, C*242.315});//{45, 280, 210}); a.push_back({A*3.838406666666667, B*288.8715555555556, C*258.89955555555554}); for(int i = 0; i < 4; i++) ans = min(ans, {dif(a[i], r), i+1}); return ans.second; }

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

artclass.cpp: In function 'int style(int, int, int (*)[500], int (*)[500], int (*)[500])':
artclass.cpp:39:23: warning: narrowing conversion of '(*(R + ((sizetype)(((long unsigned int)i) * 2000))))[j]' from 'int' to 'long double' [-Wnarrowing]
   39 |    img[i][j] = {R[i][j],G[i][j],B[i][j]};
      |                 ~~~~~~^
artclass.cpp:39:31: warning: narrowing conversion of '(*(G + ((sizetype)(((long unsigned int)i) * 2000))))[j]' from 'int' to 'long double' [-Wnarrowing]
   39 |    img[i][j] = {R[i][j],G[i][j],B[i][j]};
      |                         ~~~~~~^
artclass.cpp:39:39: warning: narrowing conversion of '(*(B + ((sizetype)(((long unsigned int)i) * 2000))))[j]' from 'int' to 'long double' [-Wnarrowing]
   39 |    img[i][j] = {R[i][j],G[i][j],B[i][j]};
      |                                 ~~~~~~^
#Verdict Execution timeMemoryGrader output
Fetching results...