Submission #434879

#TimeUsernameProblemLanguageResultExecution timeMemory
434879QCFiumArt Class (IOI13_artclass)C++14
91 / 100
122 ms6176 KiB
#include <bits/stdc++.h> #include "artclass.h" int ri() { int n; scanf("%d", &n); return n; } int value1(int h, int w, int r[500][500], int g[500][500], int b[500][500]) { auto diff = [&] (int i0, int j0, int i1, int j1) { return std::abs(r[i0][j0] - r[i1][j1]) + std::abs(g[i0][j0] - g[i1][j1]) + std::abs(b[i0][j0] - b[i1][j1]); }; int r0 = 0; for (int i = 0; i + 1 < h; i++) { for (int j = 0; j < w; j++) { int cur_diff = diff(i, j, i + 1, j); if (cur_diff > 40) r0 += cur_diff; } } int r1 = 0; for (int i = 0; i < h; i++) { for (int j = 0; j + 1 < w; j++) { int cur_diff = diff(i, j, i, j + 1); if (cur_diff > 40) r1 += cur_diff; } } int r2 = 0; for (int i = 0; i + 1 < h; i++) { for (int j = 0; j + 1 < w; j++) { int cur_diff = diff(i, j, i + 1, j + 1); if (cur_diff > 40) r2 += cur_diff; } } return std::min({r0, r1, r2}) * 10 / h / w; } int value2(int h, int w, int r[500][500], int g[500][500], int b[500][500]) { double ra = 0; double ga = 0; double ba = 0; for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) { ra += r[i][j]; ga += g[i][j]; ba += b[i][j]; } ra /= h * w; ga /= h * w; ba /= h * w; double sd = 0; for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) { double tmp = std::abs(ra - r[i][j]) + std::abs(ga - g[i][j]) + std::abs(ba - b[i][j]); sd += tmp * tmp; } sd /= h * w; return sd; } int style(int h, int w, int r[500][500], int g[500][500], int b[500][500]) { int r1 = value1(h, w, r, g, b); int r2 = value2(h, w, r, g, b); if (r1 <= 15) return 4; if (r1 >= 400) return 3; if (r2 <= 33000) return 2; return 1; }

Compilation message (stderr)

artclass.cpp: In function 'int ri()':
artclass.cpp:6:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 |  scanf("%d", &n);
      |  ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...