Submission #102866

#TimeUsernameProblemLanguageResultExecution timeMemory
102866wxh010910Art Class (IOI13_artclass)C++17
80 / 100
253 ms3452 KiB
#include <bits/stdc++.h>
#include "artclass.h"

using namespace std;

int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) {
  double ave = 0, var = 0;
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      int foo = 0, bar = 0, baz = 0;
      for (int x = i - 5; x <= i + 5; ++x) {
        for (int y = j - 5; y <= j + 5; ++y) {
          if (x >= 0 && x < H && y >= 0 && y < W) {
            foo += abs(R[x][y] - R[i][j]) + abs(G[x][y] - G[i][j]) + abs(B[x][y] - B[i][j]);
            bar += (R[x][y] - R[i][j]) * (R[x][y] - R[i][j]) + (G[x][y] - G[i][j]) * (G[x][y] - G[i][j]) + (B[x][y] - B[i][j]) * (B[x][y] - B[i][j]);
            baz += 1;
          }
        }
      }
      ave += (double) foo / baz;
      var += (double) bar / baz;
    }
  }
  ave /= 3 * H * W;
  var /= 3 * H * W;
  if (ave < 6) {
    return 4;
  } else if (ave > 30) {
    return 3;
  } else if (var > 1000) {
    return 1;
  } else {
    return 2;
  }
}
#Verdict Execution timeMemoryGrader output
Fetching results...