제출 #1076271

#제출 시각아이디문제언어결과실행 시간메모리
1076271TheQuantiX미술 수업 (IOI13_artclass)C++17
25 / 100
68 ms6340 KiB
#include <bits/stdc++.h>
#include "artclass.h"

using namespace std;
using ll = long long;

float dist(float a, float b, float c, float a1, float b1, float c1) {
    a /= 255;
    b /= 255;
    c /= 255;
    a1 /= 255;
    b1 /= 255;
    c1 /= 255;
    return (abs(a - a1) + abs(b - b1) + abs(c - c1)) / 3.;
}

float zones(int H, int W, int R[500][500], int G[500][500], int B[500][500]) {
    vector< vector<bool> > vis(H, vector<bool> (W));
    float ans = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (vis[i][j]) {
                continue;
            }
            ans++;
            queue< pair<ll, ll> > q;
            q.push({i, j});
            vis[i][j] = 1;
            while (!q.empty()) {
                auto p = q.front();
                q.pop();
                if (p.first > 0 && !vis[p.first - 1][p.second] && dist(R[p.first][p.second], G[p.first][p.second], B[p.first][p.second], R[p.first - 1][p.second], G[p.first - 1][p.second], B[p.first - 1][p.second]) < 0.2) {
                    q.push({p.first - 1, p.second});
                    vis[p.first - 1][p.second] = 1;
                }
                if (p.second > 0 && !vis[p.first][p.second - 1] && dist(R[p.first][p.second], G[p.first][p.second], B[p.first][p.second], R[p.first][p.second - 1], G[p.first][p.second - 1], B[p.first][p.second - 1]) < 0.2) {
                    q.push({p.first, p.second - 1});
                    vis[p.first][p.second - 1] = 1;
                }
                if (p.first < H - 1 && !vis[p.first + 1][p.second] && dist(R[p.first][p.second], G[p.first][p.second], B[p.first][p.second], R[p.first + 1][p.second], G[p.first + 1][p.second], B[p.first + 1][p.second]) < 0.2) {
                    q.push({p.first + 1, p.second});
                    vis[p.first + 1][p.second] = 1;
                }
                if (p.second < W - 1 && !vis[p.first][p.second + 1] && dist(R[p.first][p.second], G[p.first][p.second], B[p.first][p.second], R[p.first][p.second + 1], G[p.first][p.second + 1], B[p.first][p.second + 1]) < 0.2) {
                    q.push({p.first, p.second + 1});
                    vis[p.first][p.second + 1] = 1;
                }
            }
        }
    }
    ans /= (H / 100.);
    ans /= (W / 100.);
    return ans;
}

int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) {
    mt19937 gen(chrono::system_clock::now().time_since_epoch().count());
    auto f1 = zones(H, W, R, G, B);
    if (f1 < 0.5) {
        return 4;
    }
    else if (f1 < 40) {
        return 2;
    }
    else if (f1 < 200) {
        return 1;
    }
    else {
        return 3;
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...