Submission #367202

#TimeUsernameProblemLanguageResultExecution timeMemory
367202idk321Art Class (IOI13_artclass)C++11
25 / 100
200 ms17864 KiB
#include "artclass.h" #include <bits/stdc++.h> using namespace std; int style(int h, int w, int r[500][500], int g[500][500], int b[500][500]) { vector<int> differences; map<array<int, 3>, int> freq; int s1 = 0; int s2 = 0; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { for (int k = -1; k <= 1; k++) { for (int l = -1; l <= 1; l++) { int i2 = i + k; int j2 = j + l; if (i2 == i && j2 == j) continue; if (i2 >= 0 && i2 < h && j2 >= 0 && j2 < w) { int cdiff = abs(r[i2][j2] - r[i][j]); cdiff += abs(g[i2][j2] - g[i][j]); cdiff += abs(b[i2][j2] - b[i][j]); cdiff *= cdiff; differences.push_back(cdiff); } } } freq[{r[i][j], g[i][j], b[i][j]}]++; } } for (int i = 0; i < h; i++) { if (i != 0 && i != h - 1) continue; bool hSimilar = 1; array<int, 3> prev = {r[i][0], g[i][0], b[i][0]}; for (int j = 1; j < w; j++) { array<int, 3> cur = {r[i][j], g[i][j], b[i][j]}; int diff = 0; for (int k = 0; k < 3; k++) diff += abs(cur[k] - prev[k]); if (diff > 80) hSimilar = false; } s1 += hSimilar; } for (int j = 0; j < w; j++) { bool vSimilar = 1; if (j != 0 && j != w - 1) continue; array<int, 3> prev = {r[0][j], g[0][j], b[0][j]}; for (int i = 1; i < h; i++) { array<int, 3> cur = {r[i][j], g[i][j], b[i][j]}; int diff = 0; for (int k = 0; k < 3; k++) diff += abs(cur[k] - prev[k]); if (diff > 80) vSimilar = false; } s2 += vSimilar; } int diff = 0; double sum = 0; for (auto it = freq.begin(); it != freq.end(); it++) { sum += it->second * it->second; diff++; } if (sum / diff > 100) { double x1 = s1; x1 /= h; double x2 = s2; x2 /= w; if (s1 >= 1 || s2 >= 1) return 4; return 1; } else return 2; }
#Verdict Execution timeMemoryGrader output
Fetching results...