Submission #885524

#TimeUsernameProblemLanguageResultExecution timeMemory
885524gustavo_dArt Class (IOI13_artclass)C++17
96 / 100
55 ms6300 KiB
#include "artclass.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; mt19937 randn(time(0)); struct Pixel { int r, g, b; Pixel() { r=-1, g=-1; b=-1; } Pixel(int red, int green, int blue) { r = red; g = green; b = blue; } bool operator != (Pixel &pixel) { if (pixel.r != r or pixel.g != g or pixel.b != b) return true; return false; } }; int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) { Pixel img[H][W]; double green = 0; for (int i=0; i<H; i++) { for (int j=0; j<W; j++) { img[i][j] = Pixel(R[i][j], G[i][j], B[i][j]); if (img[i][j].g > max(img[i][j].r, img[i][j].b)) { green++; } } } green /= H * W; ll total_dist = 0; for (int i=1; i<H-1; i++) { for (int j=1; j<W-1; j++) { vector<int> dif(3); dif = {-1, 0, 1}; for (int di : dif) { for (int dj : dif) { total_dist += abs(img[i][j].r - img[i+di][j+dj].r); total_dist += abs(img[i][j].g - img[i+di][j+dj].g); total_dist += abs(img[i][j].b - img[i+di][j+dj].b); } } } } total_dist /= ((ll)H*(ll)W); // 450+ é 3 double changes = 0; for (int i=0; i<H; i++) { Pixel last = img[i][0]; for (int j=1; j<W; j++) { if (last != img[i][j]) changes++; last = img[i][j]; } } changes *= 100.0 / H; // pra porcentagem changes /= W; // 95%+ é 2 ou 3 if (changes >= 95) { if (total_dist >= 450) return 3; // dividir pelo tamanho da imagem else return 2; } else { // 1 ou 4 if (total_dist <= 100) return 4; else return 1; } return 4; }
#Verdict Execution timeMemoryGrader output
Fetching results...