Submission #426566

# Submission time Handle Problem Language Result Execution time Memory
426566 2021-06-14T06:53:49 Z Aldas25 Art Class (IOI13_artclass) C++14
49 / 100
79 ms 5236 KB
#include "artclass.h"
#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define REP(n) FOR(O, 1, (n))
#define f first
#define s second
#define pb push_back
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;

int id (int i, int j) {
    return i * 510 + j;
}

int par[520*520], sz[520*520];
int find (int a) {return par[a] = par[a]==a ? a : find(par[a]);}
bool same (int a, int b) {return find(a) == find(b);}
void unite (int a, int b) {
    a = find(a); b = find(b);
    if (a == b) return;
    par[b] = a;
    sz[a] += sz[b];
}

int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) {

    ll sumR = 0, sumG = 0, sumB = 0;
    FOR(i, 0, H-1) FOR(j, 0, W-1) {
        sumR += R[i][j];
        sumG += G[i][j];
        sumB += B[i][j];
        par[id(i,j)] = id(i,j);
        sz[id(i,j)] = 1;
    }

    //cout << " sumR = " << sumR << " sumG = " << sumG << " sumB = " << sumB << endl;
    ll area = ((ll)H)*((ll)W);
    ld avR = ((ld)sumR) / ((ld)area);
    ld avG = ((ld)sumG) / ((ld)area);
    ld avB = ((ld)sumB) / ((ld)area);
    //cout << fixed << setprecision(3) << " avR = " << avR << " avG = " << avG << " avB = " << avB << endl;

    ll maxD = 50;
    FOR(i, 0, H-1) FOR(j, 0, W-1) {
        if (i < H-1) {
            int d = 0;
            //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]);
            d = max(d, abs(R[i][j] - R[i+1][j]));
            d = max(d, abs(G[i][j] - G[i+1][j]));
            d = max(d, abs(B[i][j] - B[i+1][j]));
            if (d <= maxD)
                unite(id(i,j), id(i+1,j));
        }

        if (j < W-1) {
            int d = 0;
            d = max(d, abs(R[i][j] - R[i][j+1]));
            d = max(d, abs(G[i][j] - G[i][j+1]));
            d = max(d, abs(B[i][j] - B[i][j+1]));
            if (d <= maxD)
                unite(id(i,j), id(i,j+1));
        }
    }

    int conComponents = 0;
    FOR(i, 0, H-1) FOR(j, 0, W-1) {
        if (find(id(i,j)) != id(i,j)) continue;
        conComponents++;
    }

   // cout << " CC: " << conComponents << "\n";

    if (conComponents <= 3) return 4;
    else if (avB < min(avR, avG) - 25.0) return 2;
    else if (conComponents <= 10) return 4;
    else if (conComponents <= 500) return 1;
    else return 3;
    //cout << " ans = " << ans << endl;

    //return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 51 ms 4052 KB Output is correct
2 Correct 56 ms 5188 KB Output is correct
3 Correct 18 ms 5116 KB Output is correct
4 Correct 33 ms 2300 KB Output is correct
5 Incorrect 50 ms 4036 KB Output isn't correct
6 Correct 52 ms 4088 KB Output is correct
7 Incorrect 55 ms 4076 KB Output isn't correct
8 Correct 37 ms 2736 KB Output is correct
9 Incorrect 44 ms 5160 KB Output isn't correct
10 Correct 53 ms 5140 KB Output is correct
11 Correct 43 ms 5188 KB Output is correct
12 Incorrect 35 ms 2784 KB Output isn't correct
13 Correct 37 ms 2784 KB Output is correct
14 Correct 56 ms 4292 KB Output is correct
15 Correct 68 ms 5100 KB Output is correct
16 Correct 60 ms 5128 KB Output is correct
17 Incorrect 57 ms 5188 KB Output isn't correct
18 Correct 64 ms 5172 KB Output is correct
19 Correct 38 ms 2708 KB Output is correct
20 Correct 47 ms 5128 KB Output is correct
21 Incorrect 39 ms 5188 KB Output isn't correct
22 Correct 45 ms 5172 KB Output is correct
23 Correct 53 ms 5128 KB Output is correct
24 Correct 58 ms 4364 KB Output is correct
25 Correct 63 ms 5220 KB Output is correct
26 Correct 57 ms 5196 KB Output is correct
27 Correct 50 ms 3780 KB Output is correct
28 Correct 60 ms 4552 KB Output is correct
29 Correct 58 ms 4500 KB Output is correct
30 Correct 55 ms 5212 KB Output is correct
31 Incorrect 55 ms 3976 KB Output isn't correct
32 Incorrect 44 ms 5140 KB Output isn't correct
33 Correct 54 ms 4164 KB Output is correct
34 Correct 49 ms 5176 KB Output is correct
35 Correct 68 ms 5188 KB Output is correct
36 Incorrect 68 ms 5144 KB Output isn't correct
37 Incorrect 67 ms 5152 KB Output isn't correct
38 Correct 56 ms 5092 KB Output is correct
39 Incorrect 68 ms 5100 KB Output isn't correct
40 Correct 57 ms 4256 KB Output is correct
41 Incorrect 44 ms 3288 KB Output isn't correct
42 Incorrect 30 ms 2384 KB Output isn't correct
43 Incorrect 51 ms 4028 KB Output isn't correct
44 Correct 54 ms 4172 KB Output is correct
45 Correct 56 ms 4292 KB Output is correct
46 Incorrect 61 ms 4676 KB Output isn't correct
47 Correct 59 ms 4456 KB Output is correct
48 Incorrect 47 ms 3452 KB Output isn't correct
49 Correct 63 ms 5188 KB Output is correct
50 Correct 62 ms 4936 KB Output is correct
51 Incorrect 58 ms 4456 KB Output isn't correct
52 Correct 59 ms 5148 KB Output is correct
53 Correct 15 ms 1256 KB Output is correct
54 Incorrect 64 ms 5140 KB Output isn't correct
55 Correct 34 ms 5236 KB Output is correct
56 Correct 51 ms 3972 KB Output is correct
57 Incorrect 56 ms 5100 KB Output isn't correct
58 Correct 47 ms 5144 KB Output is correct
59 Correct 72 ms 5148 KB Output is correct
60 Correct 68 ms 5128 KB Output is correct
61 Incorrect 61 ms 5188 KB Output isn't correct
62 Incorrect 55 ms 4092 KB Output isn't correct
63 Correct 51 ms 5180 KB Output is correct
64 Correct 43 ms 5160 KB Output is correct
65 Correct 55 ms 5188 KB Output is correct
66 Correct 44 ms 5136 KB Output is correct
67 Incorrect 70 ms 5160 KB Output isn't correct
68 Incorrect 57 ms 4240 KB Output isn't correct
69 Correct 54 ms 5212 KB Output is correct
70 Correct 53 ms 5200 KB Output is correct
71 Incorrect 53 ms 4084 KB Output isn't correct
72 Correct 47 ms 3388 KB Output is correct
73 Correct 68 ms 5100 KB Output is correct
74 Incorrect 57 ms 4360 KB Output isn't correct
75 Correct 51 ms 5184 KB Output is correct
76 Incorrect 67 ms 5124 KB Output isn't correct
77 Correct 43 ms 3396 KB Output is correct
78 Correct 73 ms 5128 KB Output is correct
79 Correct 58 ms 5124 KB Output is correct
80 Correct 51 ms 3900 KB Output is correct
81 Correct 29 ms 2248 KB Output is correct
82 Correct 69 ms 5200 KB Output is correct
83 Correct 59 ms 5192 KB Output is correct
84 Incorrect 39 ms 3012 KB Output isn't correct
85 Correct 57 ms 4300 KB Output is correct
86 Incorrect 56 ms 5208 KB Output isn't correct
87 Correct 43 ms 3324 KB Output is correct
88 Incorrect 69 ms 5200 KB Output isn't correct
89 Correct 64 ms 5196 KB Output is correct
90 Correct 47 ms 5164 KB Output is correct
91 Correct 53 ms 4260 KB Output is correct
92 Incorrect 69 ms 5104 KB Output isn't correct
93 Correct 55 ms 5152 KB Output is correct
94 Correct 67 ms 5188 KB Output is correct
95 Incorrect 55 ms 4252 KB Output isn't correct
96 Incorrect 79 ms 5052 KB Output isn't correct
97 Correct 56 ms 5212 KB Output is correct
98 Incorrect 57 ms 5096 KB Output isn't correct
99 Correct 53 ms 3908 KB Output is correct
100 Correct 65 ms 5188 KB Output is correct
101 Correct 57 ms 5216 KB Output is correct
102 Correct 47 ms 5164 KB Output is correct