Submission #1195227

#TimeUsernameProblemLanguageResultExecution timeMemory
1195227ortsacArt Class (IOI13_artclass)C++20
100 / 100
36 ms3352 KiB
#include <bits/stdc++.h>
#include "artclass.h"

using namespace std;

#define ll long long
#define db long double
#define a3 array<int, 3>
#define rgb R[i][j], G[i][j], B[i][j]

int di[] = {0, -1, 1, 0};
int dj[] = {-1, 0, 0, 1};
int h, w;

bool in(int i, int j) {
    return ((i < h) && (0 <= i) && (j < w) && (0 <= j));
}

bool isWhite(int x, int y, int z) {
    if ((x + y + z) < 497) return 0;
    if (min({x, y, z}) < 154) return 0;
    return 1;
}

bool isBlack(int x, int y, int z) {
    if ((x + y + z) > 50) return 0;
    if (max({x, y, z}) > 31) return 0;
    return 1;
}

int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) {
    h = H;
    w = W;
    ll diffSides = 0;
    ll val = 0;
    int qtd = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            int mi = min({rgb});
            int mx = max({rgb});
            if (!isWhite(rgb) && !isBlack(rgb)) {
                val += (mx - mi);
                qtd++;
            }
            for (int k = 0; k < 4; k++) {
                int x = i + di[k], y = j + dj[k];
                if (!in(x, y)) continue;
                diffSides += abs(R[i][j] - R[x][y]);
                diffSides += abs(G[i][j] - G[x][y]);
                diffSides += abs(B[i][j] - B[x][y]);
            }
        }
    }
    diffSides /= (H*W);
    if (diffSides <= 35) return 4;
    //for (auto u : colors) {
    //    for (auto k : u) cout << k << " ";
    //    cout << "\n";
    //}
    //return (val/qtd);
    if ((val/qtd) > 93) return 1;
    if (diffSides <= 75) return 1;
    if (diffSides > 215) return 3;
    return 2;
}
#Verdict Execution timeMemoryGrader output
Fetching results...