Submission #680204

#TimeUsernameProblemLanguageResultExecution timeMemory
680204bashkortArt Class (IOI13_artclass)C++17
100 / 100
66 ms3860 KiB
// rainboy

#include <bits/stdc++.h>
#include "artclass.h"

using namespace std;

int style(int n, int m, int R[500][500], int G[500][500], int B[500][500]) {
    array<double, 256 * 3> cnt{};
    
    double contrast = 0;
    
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            if (i > 0) {
                int d = abs(R[i][j] - R[i - 1][j]) + abs(G[i][j] - G[i - 1][j]) + abs(B[i][j] - B[i - 1][j]);
                cnt[d] += 1;
                contrast += d;
            }
            if (j > 0) {
                int d = abs(R[i][j] - R[i][j - 1]) + abs(G[i][j] - G[i][j - 1]) + abs(B[i][j] - B[i][j - 1]);
                cnt[d] += 1;
                contrast += d;
            }
        }
    }

    contrast /= n * (m - 1) + m * (n - 1);
    
    double sameness = accumulate(cnt.begin(), cnt.begin() + 10, 0) / double(n * (m - 1) + m * (n - 1));

    if (contrast < 10) {
        return 4;
    } else if (contrast > 60) {
        return 3;
    } 
    if (sameness > 0.4) {
        return 1;
    } else {
        return 2;
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...