/**
____ ____ ____ ____ ____
||a |||t |||o |||d |||o ||
||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|
**/
#include <bits/stdc++.h>
#include "artclass.h"
using namespace std;
typedef long long ll;
const int HW_MAX = 500;
struct Color
{
int R, G, B;
};
Color weed = Color{203, 217, 76};
Color grass = Color{50, 150, 68};
Color sky = Color{180, 211, 217};
Color treeShadow = Color{8, 38, 12};
ll sq (ll a)
{
if(a < 0)
return -sqrt(-a);
return sqrt(a);
}
int dist (Color u, Color v)
{
int r = abs(u.R - v.R);
int g = abs(u.G - v.G);
int b = abs(u.B - v.B);
return sq((r * r + g * g + b * b) / 3);
}
int getMess (int H, int W, int R[HW_MAX][HW_MAX], int G[HW_MAX][HW_MAX], int B[HW_MAX][HW_MAX])
{
ll res = 0;
for(int i = 0; i < H; i++)
for(int j = 0; j < W; j++)
{
if(i > 0)
{
ll val = abs((R[i][j] + G[i][j] + B[i][j]) - (R[i - 1][j] + G[i - 1][j] + B[i - 1][j]));
res += val;
}
if(j > 0)
{
ll val = abs((R[i][j] + G[i][j] + B[i][j]) - (R[i][j - 1] + G[i][j - 1] + B[i][j - 1]));
res += val;
}
}
res /= (H * W);
return res;
}
int getNature (int H, int W, int R[HW_MAX][HW_MAX], int G[HW_MAX][HW_MAX], int B[HW_MAX][HW_MAX])
{
ll res = 0;
for(int i = 0; i < H; i++)
{
for(int j = 0; j < W; j++)
{
Color col = {R[i][j], G[i][j], B[i][j]};
int mn = INT_MAX;
mn = min(mn, dist(weed, col));
mn = min(mn, dist(grass, col));
mn = min(mn, dist(sky, col));
mn = min(mn, dist(treeShadow, col));
res += mn;
}
}
res /= (H * W);
return res;
}
int getWhite (int H, int W, int R[HW_MAX][HW_MAX], int G[HW_MAX][HW_MAX], int B[HW_MAX][HW_MAX])
{
ll res = 0;
for(int i = 0; i < H; i += 10)
for(int j = 0; j < W; j += 10)
{
int cntAll = 0;
int cntBad = 0;
for(int x = i; x < H && x < i + 10; x++)
for(int y = j; y < W && y < j + 10; y++)
{
cntAll++;
int mx = max({R[x][y], G[x][y], B[x][y]});
int mn = min({R[x][y], G[x][y], B[x][y]});
if(!(mx - mn < 40 && R[x][y] + G[x][y] + B[x][y] > 170 * 3))
cntBad++;
}
if(100 * cntBad / cntAll < 10)
res += 1000;
}
res /= (H * W / 100);
return res;
}
int getBlack (int H, int W, int R[HW_MAX][HW_MAX], int G[HW_MAX][HW_MAX], int B[HW_MAX][HW_MAX])
{
ll res = 0;
for(int i = 0; i < H; i++)
{
for(int j = 0; j < W; j++)
{
int mx = max({R[i][j], G[i][j], B[i][j]});
int mn = min({R[i][j], G[i][j], B[i][j]});
if(mx - mn < 80 && R[i][j] + G[i][j] + B[i][j] < 40 * 3 && G[i][j] > R[i][j] + 10 && G[i][j] > B[i][j] + 10)
res += 1000;
}
}
res /= (H * W);
return res;
}
int di[] = {-1, 0, 1, 0}, dj[] = {0, 1, 0, -1};
int split (int H, int W, int R[HW_MAX][HW_MAX], int G[HW_MAX][HW_MAX], int B[HW_MAX][HW_MAX])
{
int CC[HW_MAX][HW_MAX];
for(int i = 0; i < H; i++)
for(int j = 0; j < W; j++)
CC[i][j] = -1;
int cntCC = 0;
function <void (int, int)> bfs = [&] (int x, int y)
{
queue <pair <int, int>> q;
CC[x][y] = cntCC - 1;
q.push(make_pair(x, y));
while(q.empty() == false)
{
pair <int, int> p = q.front();
q.pop();
int i = p.first, j = p.second;
for(int d = 0; d < 4; d++)
{
int i1 = i + di[d], j1 = j + dj[d];
if(0 <= i1 && i1 < H && 0 <= j1 && j1 < W && CC[i1][j1] == -1)
{
int sum = 0;
sum += abs(R[i][j] - R[i1][j1]);
sum += abs(G[i][j] - G[i1][j1]);
sum += abs(B[i][j] - B[i1][j1]);
if(sum < 30 * 3)
{
CC[i1][j1] = CC[i][j];
q.push(make_pair(i1, j1));
}
}
}
}
};
for(int i = 0; i < H; i++)
for(int j = 0; j < W; j++)
if(CC[i][j] == -1)
{
cntCC++;
bfs(i, j);
}
return cntCC * 1000 / (H * W);
}
int style (int H, int W, int R[HW_MAX][HW_MAX], int G[HW_MAX][HW_MAX], int B[HW_MAX][HW_MAX])
{
int mess = getMess(H, W, R, G, B);
int nature = getNature(H, W, R, G, B);
int white = getWhite(H, W, R, G, B);
int black = getBlack(H, W, R, G, B);
int CCMess = split(H, W, R, G, B);
if(CCMess > 50)
return 3;
if(mess > 160)
return 3;
if(nature < 30)
return 2;
if(white > 200)
return 1;
if(black > 30)
return 2;
if(CCMess > 22)
return 3;
if(mess + nature > 150)
return 3;
if(mess < 20)
return 4;
return 2;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
72 ms |
4368 KB |
Output is correct |
2 |
Correct |
85 ms |
4292 KB |
Output is correct |
3 |
Correct |
69 ms |
3964 KB |
Output is correct |
4 |
Correct |
49 ms |
3376 KB |
Output is correct |
5 |
Correct |
49 ms |
4316 KB |
Output is correct |
6 |
Correct |
67 ms |
4448 KB |
Output is correct |
7 |
Correct |
18 ms |
2012 KB |
Output is correct |
8 |
Correct |
36 ms |
4336 KB |
Output is correct |
9 |
Correct |
65 ms |
4296 KB |
Output is correct |
10 |
Correct |
84 ms |
4352 KB |
Output is correct |
11 |
Correct |
60 ms |
3744 KB |
Output is correct |
12 |
Correct |
53 ms |
4328 KB |
Output is correct |
13 |
Correct |
64 ms |
3912 KB |
Output is correct |
14 |
Correct |
56 ms |
3732 KB |
Output is correct |
15 |
Correct |
39 ms |
2936 KB |
Output is correct |
16 |
Correct |
54 ms |
4292 KB |
Output is correct |
17 |
Correct |
75 ms |
4316 KB |
Output is correct |
18 |
Correct |
66 ms |
3972 KB |
Output is correct |
19 |
Correct |
44 ms |
4292 KB |
Output is correct |
20 |
Correct |
90 ms |
4344 KB |
Output is correct |
21 |
Correct |
61 ms |
4304 KB |
Output is correct |
22 |
Incorrect |
77 ms |
4388 KB |
Output isn't correct |
23 |
Correct |
63 ms |
4316 KB |
Output is correct |
24 |
Correct |
72 ms |
4388 KB |
Output is correct |
25 |
Correct |
47 ms |
4292 KB |
Output is correct |
26 |
Correct |
74 ms |
4352 KB |
Output is correct |
27 |
Incorrect |
68 ms |
4292 KB |
Output isn't correct |
28 |
Correct |
52 ms |
4408 KB |
Output is correct |
29 |
Correct |
49 ms |
4292 KB |
Output is correct |
30 |
Correct |
77 ms |
4364 KB |
Output is correct |
31 |
Correct |
66 ms |
3240 KB |
Output is correct |
32 |
Correct |
60 ms |
3652 KB |
Output is correct |
33 |
Correct |
87 ms |
3948 KB |
Output is correct |
34 |
Correct |
68 ms |
3780 KB |
Output is correct |
35 |
Correct |
71 ms |
4248 KB |
Output is correct |
36 |
Correct |
60 ms |
4292 KB |
Output is correct |
37 |
Correct |
59 ms |
3848 KB |
Output is correct |
38 |
Correct |
69 ms |
4380 KB |
Output is correct |
39 |
Incorrect |
90 ms |
3996 KB |
Output isn't correct |
40 |
Correct |
60 ms |
3764 KB |
Output is correct |
41 |
Correct |
62 ms |
4396 KB |
Output is correct |
42 |
Incorrect |
88 ms |
4400 KB |
Output isn't correct |
43 |
Correct |
63 ms |
3836 KB |
Output is correct |
44 |
Incorrect |
74 ms |
4328 KB |
Output isn't correct |
45 |
Correct |
53 ms |
3172 KB |
Output is correct |
46 |
Correct |
66 ms |
4012 KB |
Output is correct |
47 |
Correct |
59 ms |
3748 KB |
Output is correct |
48 |
Correct |
50 ms |
2920 KB |
Output is correct |
49 |
Correct |
85 ms |
4416 KB |
Output is correct |
50 |
Correct |
103 ms |
4292 KB |
Output is correct |
51 |
Correct |
34 ms |
2656 KB |
Output is correct |
52 |
Correct |
59 ms |
4312 KB |
Output is correct |
53 |
Correct |
43 ms |
2916 KB |
Output is correct |
54 |
Correct |
75 ms |
4292 KB |
Output is correct |
55 |
Correct |
64 ms |
4324 KB |
Output is correct |
56 |
Correct |
41 ms |
3012 KB |
Output is correct |
57 |
Correct |
64 ms |
3668 KB |
Output is correct |
58 |
Correct |
58 ms |
3776 KB |
Output is correct |
59 |
Incorrect |
63 ms |
4280 KB |
Output isn't correct |
60 |
Correct |
73 ms |
4332 KB |
Output is correct |
61 |
Correct |
66 ms |
3836 KB |
Output is correct |
62 |
Correct |
68 ms |
4292 KB |
Output is correct |
63 |
Correct |
63 ms |
4292 KB |
Output is correct |
64 |
Correct |
74 ms |
4244 KB |
Output is correct |
65 |
Correct |
51 ms |
4340 KB |
Output is correct |
66 |
Correct |
75 ms |
4436 KB |
Output is correct |
67 |
Correct |
51 ms |
4332 KB |
Output is correct |
68 |
Correct |
85 ms |
4332 KB |
Output is correct |
69 |
Correct |
19 ms |
4348 KB |
Output is correct |
70 |
Correct |
77 ms |
3988 KB |
Output is correct |
71 |
Correct |
80 ms |
4380 KB |
Output is correct |
72 |
Correct |
70 ms |
4396 KB |
Output is correct |
73 |
Correct |
36 ms |
2728 KB |
Output is correct |
74 |
Correct |
71 ms |
3916 KB |
Output is correct |
75 |
Incorrect |
97 ms |
4408 KB |
Output isn't correct |
76 |
Correct |
74 ms |
4376 KB |
Output is correct |
77 |
Incorrect |
74 ms |
4312 KB |
Output isn't correct |
78 |
Correct |
64 ms |
3716 KB |
Output is correct |
79 |
Correct |
68 ms |
4292 KB |
Output is correct |
80 |
Correct |
56 ms |
3376 KB |
Output is correct |
81 |
Correct |
69 ms |
3232 KB |
Output is correct |
82 |
Correct |
86 ms |
3540 KB |
Output is correct |
83 |
Correct |
60 ms |
3692 KB |
Output is correct |
84 |
Incorrect |
97 ms |
4464 KB |
Output isn't correct |
85 |
Correct |
57 ms |
3720 KB |
Output is correct |
86 |
Correct |
60 ms |
3736 KB |
Output is correct |
87 |
Correct |
61 ms |
3832 KB |
Output is correct |
88 |
Correct |
59 ms |
2956 KB |
Output is correct |
89 |
Correct |
53 ms |
4292 KB |
Output is correct |
90 |
Correct |
58 ms |
4376 KB |
Output is correct |
91 |
Correct |
43 ms |
4280 KB |
Output is correct |
92 |
Correct |
69 ms |
3600 KB |
Output is correct |
93 |
Correct |
52 ms |
4324 KB |
Output is correct |
94 |
Correct |
69 ms |
4400 KB |
Output is correct |
95 |
Correct |
62 ms |
4396 KB |
Output is correct |
96 |
Correct |
62 ms |
3908 KB |
Output is correct |
97 |
Correct |
65 ms |
4376 KB |
Output is correct |
98 |
Incorrect |
74 ms |
4396 KB |
Output isn't correct |
99 |
Correct |
57 ms |
4320 KB |
Output is correct |
100 |
Incorrect |
58 ms |
3652 KB |
Output isn't correct |
101 |
Correct |
62 ms |
2596 KB |
Output is correct |
102 |
Correct |
60 ms |
4320 KB |
Output is correct |