제출 #769630

#제출 시각아이디문제언어결과실행 시간메모리
769630fve5미술 수업 (IOI13_artclass)C++17
69 / 100
51 ms9056 KiB
#include <bits/stdc++.h>
#include "artclass.h"
using namespace std;

int diff(array<int, 3> a, array<int, 3> b) {
    return abs(a[0] - b[0]) + abs(a[1] - b[1]) + abs(a[2] - b[2]);
}

int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) {
    double difference = 0.;
    array<int, 3> img[500][500];
    for (int i = 0; i < H; i++)
        for (int j = 0; j < H; j++)
            img[i][j] = { R[i][j], G[i][j], B[i][j] };

    for (int i = 1; i < H - 1; i++) {
        for (int j = 1; j < W - 1; j++) {
            difference += diff(img[i][j], img[i - 1][j - 1])
                        + diff(img[i][j], img[i - 1][j    ])
                        + diff(img[i][j], img[i - 1][j + 1])
                        + diff(img[i][j], img[i    ][j + 1])
                        + diff(img[i][j], img[i + 1][j + 1])
                        + diff(img[i][j], img[i + 1][j    ])
                        + diff(img[i][j], img[i + 1][j - 1])
                        + diff(img[i][j], img[i    ][j - 1]);
        }
    }
    
    difference /= (H * W);

    if (difference <= 75) return 4;
    if (difference <= 220) return 1;
    if (difference <= 400) return 2;
    return 3;
}
#Verdict Execution timeMemoryGrader output
Fetching results...