#include "artclass.h"
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <cassert>
#include <vector>
#include <set>
typedef long long llong;
const int MAXN = 500;
const int INF = 1e9;
struct Cell
{
int x, y, z;
friend int operator - (const Cell &a, const Cell &b)
{
return abs(a.x - b.x) + abs(a.y - b.y) + abs(a.z - b.z);
}
friend bool operator < (const Cell &a, const Cell &b)
{
return (a.x < b.x || (a.x == b.x && a.y < b.y) || (a.x == b.x && a.y == b.y && a.z < b.z));
}
};
const int CNTBASE = 7;
int compBase[CNTBASE] = {2, 5, 10, 15, 20, 50, 100};
bool close(Cell a, Cell b, int idx)
{
return abs(a.x - b.x) < compBase[idx] && abs(a.y - b.y) < compBase[idx] && abs(a.z - b.z) < compBase[idx];
}
const int BASE = 5;
const int BASE2 = 10;
int convert(int x)
{
if (x % BASE < BASE / 2) return x - (x % BASE);
return x + BASE - (x % BASE);
}
std::set <Cell> s;
Cell pixel[MAXN][MAXN];
Cell block[MAXN][MAXN];
std::pair <int,int> delta[] = {{-1, 0}, {0, -1}, {1, 0}, {0, 1}};
bool out(int x, int y)
{
return (x == -1 || y == -1 || x == MAXN / BASE2 || y == MAXN / BASE2);
}
bool outDFS(int x, int y)
{
return (x == -1 || y == -1 || x == MAXN || y == MAXN);
}
bool vis[MAXN][MAXN][CNTBASE];
void dfs(int x, int y, int cnt)
{
vis[x][y][cnt] = true;
for (const auto &[dx, dy] : delta)
{
if (outDFS(x + dx, y + dy) || !close(pixel[x][y], pixel[x + dx][y + dy], cnt) || vis[x + dx][y + dy][cnt])
{
continue;
}
dfs(x + dx, y + dy, cnt);
}
}
int style(int H, int W, int R[500][500], int G[500][500], int B[500][500])
{
llong sum = 0;
llong green = 0;
for (int i = 0 ; i < MAXN ; ++i)
{
for (int j = 0 ; j < MAXN ; ++j)
{
sum += R[i][j];
sum += G[i][j];
sum += B[i][j];
pixel[i][j] = {R[i][j], G[i][j], B[i][j]};
block[i / BASE2][j / BASE2].x += R[i][j];
block[i / BASE2][j / BASE2].y += G[i][j];
block[i / BASE2][j / BASE2].z += B[i][j];
green += (G[i][j] > 128);
green -= (B[i][j] > 64 || G[i][j] > 64);
s.insert({convert(R[i][j]), convert(G[i][j]), convert(B[i][j])});
}
}
llong diff = 0;
llong diff2 = 0;
for (int i = 0 ; i * BASE2 < MAXN ; ++i)
{
for (int j = 0 ; j * BASE2 < MAXN ; ++j)
{
for (const auto &[dx, dy] : delta)
{
if (out(i + dx, j + dy))
{
continue;
}
diff += block[i][j] - block[i + dx][j + dy];
}
}
}
for (int i = 0 ; i < MAXN ; ++i)
{
for (int j = 0 ; j < MAXN ; ++j)
{
for (const auto &[dx, dy] : delta)
{
if (out(i + dx, j + dy))
{
continue;
}
diff2 += pixel[i][j] - pixel[i + dx][j + dy];
}
}
}
int compCnt[CNTBASE];
for (int k = 0 ; k < CNTBASE ; ++k)
{
compCnt[k] = 0;
for (int i = 0 ; i < MAXN ; ++i)
{
for (int j = 0 ; j < MAXN ; ++j)
{
if (!vis[i][j][k])
{
compCnt[k]++;
dfs(i, j, k);
}
}
}
}
for (int i = 0 ; i < CNTBASE ; ++i)
{
std::cout << compCnt[i] << ' ';
}
std::cout << '\n';
if (compCnt[6] > 10) return 3;
if (compCnt[6] <= 3 && compCnt[4] < 50) return 4;
if (compCnt[1] < 60000 && (compCnt[1] > 9000 || compCnt[4] > 150)) return 1;
if (compCnt[6] <= 3 && (compCnt[1] < 9000 || compCnt[4] < 150)) return 4;
if (compCnt[6] <= 5 && compCnt[4] < 15000) return 2;
return 3;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
127 ms |
31564 KB |
Output isn't correct |
2 |
Incorrect |
136 ms |
27564 KB |
Output isn't correct |
3 |
Incorrect |
119 ms |
24324 KB |
Output isn't correct |
4 |
Incorrect |
135 ms |
31580 KB |
Output isn't correct |
5 |
Incorrect |
108 ms |
26956 KB |
Output isn't correct |
6 |
Incorrect |
115 ms |
31420 KB |
Output isn't correct |
7 |
Incorrect |
117 ms |
26396 KB |
Output isn't correct |
8 |
Incorrect |
108 ms |
21496 KB |
Output isn't correct |
9 |
Incorrect |
119 ms |
28428 KB |
Output isn't correct |
10 |
Incorrect |
128 ms |
27440 KB |
Output isn't correct |
11 |
Incorrect |
149 ms |
30772 KB |
Output isn't correct |
12 |
Incorrect |
132 ms |
28124 KB |
Output isn't correct |
13 |
Incorrect |
123 ms |
27720 KB |
Output isn't correct |
14 |
Incorrect |
119 ms |
28640 KB |
Output isn't correct |
15 |
Incorrect |
122 ms |
29516 KB |
Output isn't correct |
16 |
Incorrect |
129 ms |
28108 KB |
Output isn't correct |
17 |
Incorrect |
128 ms |
31676 KB |
Output isn't correct |
18 |
Incorrect |
111 ms |
28636 KB |
Output isn't correct |
19 |
Incorrect |
102 ms |
29004 KB |
Output isn't correct |
20 |
Incorrect |
119 ms |
29016 KB |
Output isn't correct |
21 |
Incorrect |
115 ms |
26656 KB |
Output isn't correct |
22 |
Incorrect |
135 ms |
30156 KB |
Output isn't correct |
23 |
Incorrect |
126 ms |
30256 KB |
Output isn't correct |
24 |
Incorrect |
109 ms |
26960 KB |
Output isn't correct |
25 |
Incorrect |
117 ms |
21748 KB |
Output isn't correct |
26 |
Incorrect |
126 ms |
29400 KB |
Output isn't correct |
27 |
Incorrect |
111 ms |
24844 KB |
Output isn't correct |
28 |
Incorrect |
117 ms |
29644 KB |
Output isn't correct |
29 |
Incorrect |
128 ms |
26704 KB |
Output isn't correct |
30 |
Incorrect |
150 ms |
28508 KB |
Output isn't correct |
31 |
Incorrect |
114 ms |
31588 KB |
Output isn't correct |
32 |
Incorrect |
115 ms |
27576 KB |
Output isn't correct |
33 |
Incorrect |
120 ms |
24384 KB |
Output isn't correct |
34 |
Incorrect |
156 ms |
31408 KB |
Output isn't correct |
35 |
Incorrect |
133 ms |
31624 KB |
Output isn't correct |
36 |
Incorrect |
117 ms |
26572 KB |
Output isn't correct |
37 |
Incorrect |
113 ms |
28372 KB |
Output isn't correct |
38 |
Incorrect |
126 ms |
30256 KB |
Output isn't correct |
39 |
Incorrect |
123 ms |
31992 KB |
Output isn't correct |
40 |
Incorrect |
127 ms |
31160 KB |
Output isn't correct |
41 |
Incorrect |
126 ms |
26572 KB |
Output isn't correct |
42 |
Incorrect |
118 ms |
25280 KB |
Output isn't correct |
43 |
Incorrect |
125 ms |
29788 KB |
Output isn't correct |
44 |
Incorrect |
110 ms |
25544 KB |
Output isn't correct |
45 |
Incorrect |
123 ms |
27936 KB |
Output isn't correct |
46 |
Incorrect |
135 ms |
30368 KB |
Output isn't correct |
47 |
Incorrect |
122 ms |
31716 KB |
Output isn't correct |
48 |
Incorrect |
125 ms |
29772 KB |
Output isn't correct |
49 |
Incorrect |
98 ms |
19700 KB |
Output isn't correct |
50 |
Incorrect |
113 ms |
26784 KB |
Output isn't correct |
51 |
Incorrect |
103 ms |
20552 KB |
Output isn't correct |
52 |
Incorrect |
104 ms |
21872 KB |
Output isn't correct |
53 |
Incorrect |
113 ms |
24948 KB |
Output isn't correct |
54 |
Incorrect |
112 ms |
29728 KB |
Output isn't correct |
55 |
Incorrect |
106 ms |
22436 KB |
Output isn't correct |
56 |
Incorrect |
103 ms |
25384 KB |
Output isn't correct |
57 |
Incorrect |
123 ms |
29332 KB |
Output isn't correct |
58 |
Incorrect |
128 ms |
31760 KB |
Output isn't correct |
59 |
Incorrect |
122 ms |
23640 KB |
Output isn't correct |
60 |
Incorrect |
128 ms |
27468 KB |
Output isn't correct |
61 |
Incorrect |
109 ms |
27268 KB |
Output isn't correct |
62 |
Incorrect |
127 ms |
31744 KB |
Output isn't correct |
63 |
Incorrect |
117 ms |
27236 KB |
Output isn't correct |
64 |
Incorrect |
109 ms |
27852 KB |
Output isn't correct |
65 |
Incorrect |
113 ms |
24192 KB |
Output isn't correct |
66 |
Incorrect |
119 ms |
27836 KB |
Output isn't correct |
67 |
Incorrect |
120 ms |
25712 KB |
Output isn't correct |
68 |
Incorrect |
116 ms |
21480 KB |
Output isn't correct |
69 |
Incorrect |
110 ms |
31712 KB |
Output isn't correct |
70 |
Incorrect |
103 ms |
21956 KB |
Output isn't correct |
71 |
Incorrect |
123 ms |
29900 KB |
Output isn't correct |
72 |
Incorrect |
119 ms |
23112 KB |
Output isn't correct |
73 |
Incorrect |
115 ms |
29952 KB |
Output isn't correct |
74 |
Incorrect |
109 ms |
27756 KB |
Output isn't correct |
75 |
Incorrect |
127 ms |
30492 KB |
Output isn't correct |
76 |
Incorrect |
132 ms |
29784 KB |
Output isn't correct |
77 |
Incorrect |
114 ms |
27596 KB |
Output isn't correct |
78 |
Incorrect |
113 ms |
31232 KB |
Output isn't correct |
79 |
Incorrect |
124 ms |
28568 KB |
Output isn't correct |
80 |
Incorrect |
122 ms |
31560 KB |
Output isn't correct |
81 |
Incorrect |
108 ms |
31564 KB |
Output isn't correct |
82 |
Incorrect |
125 ms |
25540 KB |
Output isn't correct |
83 |
Incorrect |
120 ms |
27228 KB |
Output isn't correct |
84 |
Incorrect |
115 ms |
25920 KB |
Output isn't correct |
85 |
Incorrect |
138 ms |
29184 KB |
Output isn't correct |
86 |
Incorrect |
118 ms |
23940 KB |
Output isn't correct |
87 |
Incorrect |
123 ms |
31692 KB |
Output isn't correct |
88 |
Incorrect |
119 ms |
31752 KB |
Output isn't correct |
89 |
Incorrect |
120 ms |
28988 KB |
Output isn't correct |
90 |
Incorrect |
121 ms |
28820 KB |
Output isn't correct |
91 |
Incorrect |
153 ms |
30636 KB |
Output isn't correct |
92 |
Incorrect |
116 ms |
26364 KB |
Output isn't correct |
93 |
Incorrect |
111 ms |
22516 KB |
Output isn't correct |
94 |
Incorrect |
113 ms |
30620 KB |
Output isn't correct |
95 |
Incorrect |
109 ms |
20056 KB |
Output isn't correct |
96 |
Incorrect |
118 ms |
27964 KB |
Output isn't correct |
97 |
Incorrect |
111 ms |
31692 KB |
Output isn't correct |
98 |
Incorrect |
110 ms |
24412 KB |
Output isn't correct |
99 |
Incorrect |
133 ms |
27732 KB |
Output isn't correct |
100 |
Incorrect |
124 ms |
29968 KB |
Output isn't correct |
101 |
Incorrect |
124 ms |
27336 KB |
Output isn't correct |
102 |
Incorrect |
106 ms |
23788 KB |
Output isn't correct |