제출 #369341

#제출 시각아이디문제언어결과실행 시간메모리
369341kostia244미술 수업 (IOI13_artclass)C++17
98 / 100
108 ms15212 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; } ld uwu() { ld sum = 0; for(int i = 0; i+1 < n; i++) for(int j = 0; j < m; j++) sum += (img[i][j][1]-img[i+1][j][1])*(img[i][j][1]-img[i+1][j][1]); for(int i = 0; i < n; i++) for(int j = 0; j+1 < m; j++) sum += (img[i][j][1]-img[i][j+1][1])*(img[i][j][1]-img[i][j+1][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 = uwu(); #define B aaa const int A = 3; const int B = 1; const int C = 1; vec r = {A*f, B*g, C*h}; pair<ld, int> ans = {1<<30, 0}; //cout << f << " " << g << " " << h << endl; vector<vec> a; a.push_back({A* 11.171448888888888 ,B* 163.45119999999997 ,C* 285.9314333333333});//{10, 160, 290}); a.push_back({A* 19.13388888888889 ,B* 292.3247777777778 ,C* 264.59866666666665});//{17, 280, 210}); a.push_back({A* 50.98616666666666 ,B* 228.85688888888888 ,C* 1719.4388888888889});//{45, 280, 210}); a.push_back({A* 3.838406666666667 ,B* 288.8715555555556 ,C* 15.933765555555555}); 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:50:23: warning: narrowing conversion of '(*(R + ((sizetype)(((long unsigned int)i) * 2000))))[j]' from 'int' to 'long double' [-Wnarrowing]
   50 |    img[i][j] = {R[i][j],G[i][j],B[i][j]};
      |                 ~~~~~~^
artclass.cpp:50:31: warning: narrowing conversion of '(*(G + ((sizetype)(((long unsigned int)i) * 2000))))[j]' from 'int' to 'long double' [-Wnarrowing]
   50 |    img[i][j] = {R[i][j],G[i][j],B[i][j]};
      |                         ~~~~~~^
artclass.cpp:50:39: warning: narrowing conversion of '(*(B + ((sizetype)(((long unsigned int)i) * 2000))))[j]' from 'int' to 'long double' [-Wnarrowing]
   50 |    img[i][j] = {R[i][j],G[i][j],B[i][j]};
      |                                 ~~~~~~^
#Verdict Execution timeMemoryGrader output
Fetching results...