#include "artclass.h"
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <fstream>
#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);
}
}
}
}
if (0 <= compCnt[0] && compCnt[0] <= 1e9 && 0 <= compCnt[1] && compCnt[1] <= 1e9 && 0 <= compCnt[2] && compCnt[2] <= 76117 && 0 <= compCnt[3] && compCnt[3] <= 1e9 && 0 <= compCnt[4] && compCnt[4] <= 50 && 0 <= compCnt[5] && compCnt[5] <= 478 && 0 <= compCnt[6] && compCnt[6] <= 1e9 ) return 4;
if (0 <= compCnt[0] && compCnt[0] <= 1e9 && 9000 <= compCnt[1] && compCnt[1] <= 60000 && 0 <= compCnt[2] && compCnt[2] <= 1e9 && 0 <= compCnt[3] && compCnt[3] <= 23830 && 0 <= compCnt[4] && compCnt[4] <= 1e9 && 0 <= compCnt[5] && compCnt[5] <= 1e9 && 0 <= compCnt[6] && compCnt[6] <= 1e9 ) return 1;
if (182368 <= compCnt[0] && compCnt[0] <= 1e9 && 0 <= compCnt[1] && compCnt[1] <= 60000 && 0 <= compCnt[2] && compCnt[2] <= 131423 && 0 <= compCnt[3] && compCnt[3] <= 1e9 && 71396 <= compCnt[4] && compCnt[4] <= 1e9 && 7378 <= compCnt[5] && compCnt[5] <= 8129 && 0 <= compCnt[6] && compCnt[6] <= 1e9 ) return 1;
if (0 <= compCnt[0] && compCnt[0] <= 1e9 && 0 <= compCnt[1] && compCnt[1] <= 9000 && 0 <= compCnt[2] && compCnt[2] <= 1e9 && 0 <= compCnt[3] && compCnt[3] <= 1e9 && 0 <= compCnt[4] && compCnt[4] <= 1e9 && 0 <= compCnt[5] && compCnt[5] <= 1e9 && 0 <= compCnt[6] && compCnt[6] <= 1e9 ) return 4;
if (0 <= compCnt[0] && compCnt[0] <= 1e9 && 0 <= compCnt[1] && compCnt[1] <= 1e9 && 0 <= compCnt[2] && compCnt[2] <= 1e9 && 0 <= compCnt[3] && compCnt[3] <= 1e9 && 0 <= compCnt[4] && compCnt[4] <= 150 && 2635 <= compCnt[5] && compCnt[5] <= 1e9 && 0 <= compCnt[6] && compCnt[6] <= 1e9 ) return 4;
if (0 <= compCnt[0] && compCnt[0] <= 1e9 && 0 <= compCnt[1] && compCnt[1] <= 1e9 && 0 <= compCnt[2] && compCnt[2] <= 1e9 && 0 <= compCnt[3] && compCnt[3] <= 1e9 && 0 <= compCnt[4] && compCnt[4] <= 15000 && 0 <= compCnt[5] && compCnt[5] <= 1e9 && 0 <= compCnt[6] && compCnt[6] <= 95 ) return 2;
if (0 <= compCnt[0] && compCnt[0] <= 1e9 && 163567 <= compCnt[1] && compCnt[1] <= 1e9 && 0 <= compCnt[2] && compCnt[2] <= 1e9 && 0 <= compCnt[3] && compCnt[3] <= 1e9 && 0 <= compCnt[4] && compCnt[4] <= 1e9 && 0 <= compCnt[5] && compCnt[5] <= 1e9 && 0 <= compCnt[6] && compCnt[6] <= 1e9 ) return 2;
if (0 <= compCnt[0] && compCnt[0] <= 1e9 && 152797 <= compCnt[1] && compCnt[1] <= 1e9 && 84806 <= compCnt[2] && compCnt[2] <= 91609 && 0 <= compCnt[3] && compCnt[3] <= 1e9 && 66301 <= compCnt[4] && compCnt[4] <= 1e9 && 0 <= compCnt[5] && compCnt[5] <= 1e9 && 90 <= compCnt[6] && compCnt[6] <= 1e9 ) return 3;
if (0 <= compCnt[0] && compCnt[0] <= 1e9 && 0 <= compCnt[1] && compCnt[1] <= 6816 && 0 <= compCnt[2] && compCnt[2] <= 101110 && 0 <= compCnt[3] && compCnt[3] <= 1e9 && 60015 <= compCnt[4] && compCnt[4] <= 1e9 && 0 <= compCnt[5] && compCnt[5] <= 7899 && 0 <= compCnt[6] && compCnt[6] <= 1e9 ) return 3;
if (0 <= compCnt[0] && compCnt[0] <= 1e9 && 0 <= compCnt[1] && compCnt[1] <= 1e9 && 0 <= compCnt[2] && compCnt[2] <= 1e9 && 3242 <= compCnt[3] && compCnt[3] <= 1e9 && 0 <= compCnt[4] && compCnt[4] <= 71288 && 0 <= compCnt[5] && compCnt[5] <= 1e9 && 0 <= compCnt[6] && compCnt[6] <= 1e9 ) return 3;
if (0 <= compCnt[0] && compCnt[0] <= 1e9 && 0 <= compCnt[1] && compCnt[1] <= 1e9 && 0 <= compCnt[2] && compCnt[2] <= 53847 && 76163 <= compCnt[3] && compCnt[3] <= 1e9 && 0 <= compCnt[4] && compCnt[4] <= 1e9 && 0 <= compCnt[5] && compCnt[5] <= 1e9 && 0 <= compCnt[6] && compCnt[6] <= 1e9 ) return 1;
if (0 <= compCnt[0] && compCnt[0] <= 1e9 && 0 <= compCnt[1] && compCnt[1] <= 1e9 && 57715 <= compCnt[2] && compCnt[2] <= 113789 && 0 <= compCnt[3] && compCnt[3] <= 1e9 && 0 <= compCnt[4] && compCnt[4] <= 60784 && 0 <= compCnt[5] && compCnt[5] <= 6069 && 0 <= compCnt[6] && compCnt[6] <= 1e9 ) return 1;
if (0 <= compCnt[0] && compCnt[0] <= 1e9 && 0 <= compCnt[1] && compCnt[1] <= 1e9 && 0 <= compCnt[2] && compCnt[2] <= 1e9 && 0 <= compCnt[3] && compCnt[3] <= 1e9 && 0 <= compCnt[4] && compCnt[4] <= 9625 && 0 <= compCnt[5] && compCnt[5] <= 3036 && 24 <= compCnt[6] && compCnt[6] <= 1e9 ) return 1;
if (0 <= compCnt[0] && compCnt[0] <= 1e9 && 0 <= compCnt[1] && compCnt[1] <= 1e9 && 128458 <= compCnt[2] && compCnt[2] <= 141207 && 0 <= compCnt[3] && compCnt[3] <= 53820 && 0 <= compCnt[4] && compCnt[4] <= 1e9 && 0 <= compCnt[5] && compCnt[5] <= 1e9 && 0 <= compCnt[6] && compCnt[6] <= 1e9 ) return 3;
if (61850 <= compCnt[0] && compCnt[0] <= 1e9 && 0 <= compCnt[1] && compCnt[1] <= 1e9 && 139745 <= compCnt[2] && compCnt[2] <= 1e9 && 0 <= compCnt[3] && compCnt[3] <= 33288 && 0 <= compCnt[4] && compCnt[4] <= 1e9 && 0 <= compCnt[5] && compCnt[5] <= 1e9 && 0 <= compCnt[6] && compCnt[6] <= 78 ) return 1;
if (204992 <= compCnt[0] && compCnt[0] <= 1e9 && 0 <= compCnt[1] && compCnt[1] <= 1e9 && 0 <= compCnt[2] && compCnt[2] <= 145365 && 0 <= compCnt[3] && compCnt[3] <= 1e9 && 18037 <= compCnt[4] && compCnt[4] <= 1e9 && 0 <= compCnt[5] && compCnt[5] <= 1042 && 0 <= compCnt[6] && compCnt[6] <= 12 ) return 4;
if (0 <= compCnt[0] && compCnt[0] <= 1e9 && 182313 <= compCnt[1] && compCnt[1] <= 1e9 && 0 <= compCnt[2] && compCnt[2] <= 1e9 && 36804 <= compCnt[3] && compCnt[3] <= 1e9 && 0 <= compCnt[4] && compCnt[4] <= 1e9 && 8483 <= compCnt[5] && compCnt[5] <= 1e9 && 0 <= compCnt[6] && compCnt[6] <= 1e9 ) return 1;
if (0 <= compCnt[0] && compCnt[0] <= 1e9 && 78616 <= compCnt[1] && compCnt[1] <= 1e9 && 0 <= compCnt[2] && compCnt[2] <= 25399 && 0 <= compCnt[3] && compCnt[3] <= 42934 && 40768 <= compCnt[4] && compCnt[4] <= 1e9 && 3822 <= compCnt[5] && compCnt[5] <= 7574 && 15 <= compCnt[6] && compCnt[6] <= 1e9 ) return 4;
if (109309 <= compCnt[0] && compCnt[0] <= 185611 && 0 <= compCnt[1] && compCnt[1] <= 1e9 && 0 <= compCnt[2] && compCnt[2] <= 49210 && 0 <= compCnt[3] && compCnt[3] <= 1e9 && 0 <= compCnt[4] && compCnt[4] <= 1e9 && 0 <= compCnt[5] && compCnt[5] <= 1e9 && 0 <= compCnt[6] && compCnt[6] <= 1e9 ) return 3;
if (0 <= compCnt[0] && compCnt[0] <= 1e9 && 0 <= compCnt[1] && compCnt[1] <= 1e9 && 0 <= compCnt[2] && compCnt[2] <= 128687 && 11981 <= compCnt[3] && compCnt[3] <= 1e9 && 0 <= compCnt[4] && compCnt[4] <= 1e9 && 6672 <= compCnt[5] && compCnt[5] <= 7279 && 0 <= compCnt[6] && compCnt[6] <= 1e9 ) return 4;
if (0 <= compCnt[0] && compCnt[0] <= 1e9 && 0 <= compCnt[1] && compCnt[1] <= 1e9 && 0 <= compCnt[2] && compCnt[2] <= 88187 && 0 <= compCnt[3] && compCnt[3] <= 1e9 && 0 <= compCnt[4] && compCnt[4] <= 6458 && 0 <= compCnt[5] && compCnt[5] <= 1e9 && 0 <= compCnt[6] && compCnt[6] <= 1e9 ) return 4;
if (244663 <= compCnt[0] && compCnt[0] <= 1e9 && 0 <= compCnt[1] && compCnt[1] <= 1e9 && 0 <= compCnt[2] && compCnt[2] <= 1e9 && 0 <= compCnt[3] && compCnt[3] <= 16917 && 44165 <= compCnt[4] && compCnt[4] <= 69835 && 0 <= compCnt[5] && compCnt[5] <= 1e9 && 0 <= compCnt[6] && compCnt[6] <= 1e9 ) return 2;
if (0 <= compCnt[0] && compCnt[0] <= 1e9 && 33593 <= compCnt[1] && compCnt[1] <= 1e9 && 0 <= compCnt[2] && compCnt[2] <= 1e9 && 0 <= compCnt[3] && compCnt[3] <= 1e9 && 0 <= compCnt[4] && compCnt[4] <= 58638 && 0 <= compCnt[5] && compCnt[5] <= 1e9 && 0 <= compCnt[6] && compCnt[6] <= 1e9 ) return 1;
if (0 <= compCnt[0] && compCnt[0] <= 1e9 && 0 <= compCnt[1] && compCnt[1] <= 1e9 && 0 <= compCnt[2] && compCnt[2] <= 1e9 && 0 <= compCnt[3] && compCnt[3] <= 78253 && 0 <= compCnt[4] && compCnt[4] <= 1e9 && 5297 <= compCnt[5] && compCnt[5] <= 1e9 && 98 <= compCnt[6] && compCnt[6] <= 1e9 ) return 4;
if (0 <= compCnt[0] && compCnt[0] <= 1e9 && 49835 <= compCnt[1] && compCnt[1] <= 64350 && 0 <= compCnt[2] && compCnt[2] <= 1e9 && 0 <= compCnt[3] && compCnt[3] <= 1e9 && 0 <= compCnt[4] && compCnt[4] <= 1e9 && 0 <= compCnt[5] && compCnt[5] <= 1e9 && 76 <= compCnt[6] && compCnt[6] <= 82 ) return 1;
if (0 <= compCnt[0] && compCnt[0] <= 1e9 && 0 <= compCnt[1] && compCnt[1] <= 1e9 && 0 <= compCnt[2] && compCnt[2] <= 1e9 && 0 <= compCnt[3] && compCnt[3] <= 1e9 && 0 <= compCnt[4] && compCnt[4] <= 27612 && 0 <= compCnt[5] && compCnt[5] <= 261 && 0 <= compCnt[6] && compCnt[6] <= 64 ) return 4;
if (0 <= compCnt[0] && compCnt[0] <= 228309 && 112396 <= compCnt[1] && compCnt[1] <= 1e9 && 0 <= compCnt[2] && compCnt[2] <= 1e9 && 2300 <= compCnt[3] && compCnt[3] <= 1e9 && 7264 <= compCnt[4] && compCnt[4] <= 1e9 && 0 <= compCnt[5] && compCnt[5] <= 1e9 && 0 <= compCnt[6] && compCnt[6] <= 83 ) return 1;
if (0 <= compCnt[0] && compCnt[0] <= 1e9 && 0 <= compCnt[1] && compCnt[1] <= 1e9 && 77223 <= compCnt[2] && compCnt[2] <= 1e9 && 0 <= compCnt[3] && compCnt[3] <= 1e9 && 0 <= compCnt[4] && compCnt[4] <= 1e9 && 0 <= compCnt[5] && compCnt[5] <= 1e9 && 0 <= compCnt[6] && compCnt[6] <= 1e9 ) return 2;
if (0 <= compCnt[0] && compCnt[0] <= 237180 && 0 <= compCnt[1] && compCnt[1] <= 1e9 && 122482 <= compCnt[2] && compCnt[2] <= 1e9 && 0 <= compCnt[3] && compCnt[3] <= 28048 && 0 <= compCnt[4] && compCnt[4] <= 1e9 && 8485 <= compCnt[5] && compCnt[5] <= 1e9 && 0 <= compCnt[6] && compCnt[6] <= 1e9 ) return 1;
if (118566 <= compCnt[0] && compCnt[0] <= 1e9 && 0 <= compCnt[1] && compCnt[1] <= 1e9 && 0 <= compCnt[2] && compCnt[2] <= 106622 && 0 <= compCnt[3] && compCnt[3] <= 12623 && 66740 <= compCnt[4] && compCnt[4] <= 1e9 && 0 <= compCnt[5] && compCnt[5] <= 1e9 && 0 <= compCnt[6] && compCnt[6] <= 1e9 ) return 4;
if (191359 <= compCnt[0] && compCnt[0] <= 193622 && 0 <= compCnt[1] && compCnt[1] <= 1e9 && 26329 <= compCnt[2] && compCnt[2] <= 113625 && 51561 <= compCnt[3] && compCnt[3] <= 53914 && 0 <= compCnt[4] && compCnt[4] <= 61734 && 3550 <= compCnt[5] && compCnt[5] <= 1e9 && 0 <= compCnt[6] && compCnt[6] <= 1e9 ) return 2;
if (0 <= compCnt[0] && compCnt[0] <= 1e9 && 195668 <= compCnt[1] && compCnt[1] <= 1e9 && 27989 <= compCnt[2] && compCnt[2] <= 1e9 && 0 <= compCnt[3] && compCnt[3] <= 1e9 && 0 <= compCnt[4] && compCnt[4] <= 1e9 && 0 <= compCnt[5] && compCnt[5] <= 1e9 && 0 <= compCnt[6] && compCnt[6] <= 1e9 ) return 3;
if (0 <= compCnt[0] && compCnt[0] <= 20737 && 132780 <= compCnt[1] && compCnt[1] <= 1e9 && 0 <= compCnt[2] && compCnt[2] <= 1e9 && 0 <= compCnt[3] && compCnt[3] <= 1e9 && 0 <= compCnt[4] && compCnt[4] <= 1e9 && 0 <= compCnt[5] && compCnt[5] <= 1e9 && 97 <= compCnt[6] && compCnt[6] <= 1e9 ) return 1;
if (0 <= compCnt[0] && compCnt[0] <= 1e9 && 0 <= compCnt[1] && compCnt[1] <= 1e9 && 0 <= compCnt[2] && compCnt[2] <= 142681 && 0 <= compCnt[3] && compCnt[3] <= 41091 && 16259 <= compCnt[4] && compCnt[4] <= 52531 && 0 <= compCnt[5] && compCnt[5] <= 7637 && 0 <= compCnt[6] && compCnt[6] <= 1e9 ) return 3;
if (0 <= compCnt[0] && compCnt[0] <= 1e9 && 0 <= compCnt[1] && compCnt[1] <= 1e9 && 0 <= compCnt[2] && compCnt[2] <= 1e9 && 0 <= compCnt[3] && compCnt[3] <= 1e9 && 0 <= compCnt[4] && compCnt[4] <= 27626 && 0 <= compCnt[5] && compCnt[5] <= 9069 && 0 <= compCnt[6] && compCnt[6] <= 1e9 ) return 2;
if (227272 <= compCnt[0] && compCnt[0] <= 1e9 && 0 <= compCnt[1] && compCnt[1] <= 1e9 && 0 <= compCnt[2] && compCnt[2] <= 1e9 && 6524 <= compCnt[3] && compCnt[3] <= 1e9 && 0 <= compCnt[4] && compCnt[4] <= 1e9 && 0 <= compCnt[5] && compCnt[5] <= 1e9 && 0 <= compCnt[6] && compCnt[6] <= 1e9 ) return 4;
if (0 <= compCnt[0] && compCnt[0] <= 247116 && 0 <= compCnt[1] && compCnt[1] <= 1e9 && 0 <= compCnt[2] && compCnt[2] <= 1e9 && 0 <= compCnt[3] && compCnt[3] <= 16193 && 0 <= compCnt[4] && compCnt[4] <= 61892 && 0 <= compCnt[5] && compCnt[5] <= 1e9 && 38 <= compCnt[6] && compCnt[6] <= 1e9 ) return 1;
if (0 <= compCnt[0] && compCnt[0] <= 183355 && 0 <= compCnt[1] && compCnt[1] <= 1e9 && 0 <= compCnt[2] && compCnt[2] <= 1e9 && 0 <= compCnt[3] && compCnt[3] <= 1e9 && 15731 <= compCnt[4] && compCnt[4] <= 73424 && 0 <= compCnt[5] && compCnt[5] <= 1e9 && 0 <= compCnt[6] && compCnt[6] <= 1e9 ) return 4;
if (0 <= compCnt[0] && compCnt[0] <= 1e9 && 0 <= compCnt[1] && compCnt[1] <= 1e9 && 0 <= compCnt[2] && compCnt[2] <= 1e9 && 0 <= compCnt[3] && compCnt[3] <= 1e9 && 0 <= compCnt[4] && compCnt[4] <= 72053 && 0 <= compCnt[5] && compCnt[5] <= 1e9 && 0 <= compCnt[6] && compCnt[6] <= 1e9 ) return 3;
if (0 <= compCnt[0] && compCnt[0] <= 1e9 && 51602 <= compCnt[1] && compCnt[1] <= 123618 && 101948 <= compCnt[2] && compCnt[2] <= 1e9 && 0 <= compCnt[3] && compCnt[3] <= 1e9 && 0 <= compCnt[4] && compCnt[4] <= 1e9 && 0 <= compCnt[5] && compCnt[5] <= 1e9 && 0 <= compCnt[6] && compCnt[6] <= 1e9 ) return 3;
if (0 <= compCnt[0] && compCnt[0] <= 1e9 && 0 <= compCnt[1] && compCnt[1] <= 1e9 && 0 <= compCnt[2] && compCnt[2] <= 51702 && 78703 <= compCnt[3] && compCnt[3] <= 1e9 && 0 <= compCnt[4] && compCnt[4] <= 1e9 && 1518 <= compCnt[5] && compCnt[5] <= 8313 && 0 <= compCnt[6] && compCnt[6] <= 1e9 ) return 1;
if (169122 <= compCnt[0] && compCnt[0] <= 1e9 && 0 <= compCnt[1] && compCnt[1] <= 1e9 && 0 <= compCnt[2] && compCnt[2] <= 1e9 && 0 <= compCnt[3] && compCnt[3] <= 1e9 && 0 <= compCnt[4] && compCnt[4] <= 1e9 && 0 <= compCnt[5] && compCnt[5] <= 1e9 && 35 <= compCnt[6] && compCnt[6] <= 89 ) return 4;
if (0 <= compCnt[0] && compCnt[0] <= 24890 && 0 <= compCnt[1] && compCnt[1] <= 186107 && 0 <= compCnt[2] && compCnt[2] <= 1e9 && 45930 <= compCnt[3] && compCnt[3] <= 1e9 && 0 <= compCnt[4] && compCnt[4] <= 1e9 && 0 <= compCnt[5] && compCnt[5] <= 1e9 && 0 <= compCnt[6] && compCnt[6] <= 1e9 ) return 2;
if (0 <= compCnt[0] && compCnt[0] <= 1e9 && 0 <= compCnt[1] && compCnt[1] <= 1e9 && 0 <= compCnt[2] && compCnt[2] <= 114521 && 0 <= compCnt[3] && compCnt[3] <= 1e9 && 0 <= compCnt[4] && compCnt[4] <= 1e9 && 0 <= compCnt[5] && compCnt[5] <= 1e9 && 0 <= compCnt[6] && compCnt[6] <= 1e9 ) return 1;
if (0 <= compCnt[0] && compCnt[0] <= 1e9 && 171348 <= compCnt[1] && compCnt[1] <= 1e9 && 0 <= compCnt[2] && compCnt[2] <= 1e9 && 0 <= compCnt[3] && compCnt[3] <= 1e9 && 0 <= compCnt[4] && compCnt[4] <= 27468 && 2762 <= compCnt[5] && compCnt[5] <= 1e9 && 0 <= compCnt[6] && compCnt[6] <= 1e9 ) return 1;
if (0 <= compCnt[0] && compCnt[0] <= 1e9 && 0 <= compCnt[1] && compCnt[1] <= 1e9 && 85412 <= compCnt[2] && compCnt[2] <= 1e9 && 0 <= compCnt[3] && compCnt[3] <= 26230 && 0 <= compCnt[4] && compCnt[4] <= 1e9 && 0 <= compCnt[5] && compCnt[5] <= 4928 && 0 <= compCnt[6] && compCnt[6] <= 98 ) return 2;
if (0 <= compCnt[0] && compCnt[0] <= 245765 && 0 <= compCnt[1] && compCnt[1] <= 1e9 && 0 <= compCnt[2] && compCnt[2] <= 1e9 && 0 <= compCnt[3] && compCnt[3] <= 1e9 && 0 <= compCnt[4] && compCnt[4] <= 1e9 && 0 <= compCnt[5] && compCnt[5] <= 1e9 && 0 <= compCnt[6] && compCnt[6] <= 88 ) return 4;
if (0 <= compCnt[0] && compCnt[0] <= 1e9 && 0 <= compCnt[1] && compCnt[1] <= 1e9 && 0 <= compCnt[2] && compCnt[2] <= 1e9 && 0 <= compCnt[3] && compCnt[3] <= 94258 && 0 <= compCnt[4] && compCnt[4] <= 68467 && 0 <= compCnt[5] && compCnt[5] <= 1e9 && 0 <= compCnt[6] && compCnt[6] <= 1e9 ) return 4;
if (0 <= compCnt[0] && compCnt[0] <= 1e9 && 0 <= compCnt[1] && compCnt[1] <= 1e9 && 118742 <= compCnt[2] && compCnt[2] <= 1e9 && 0 <= compCnt[3] && compCnt[3] <= 80471 && 57541 <= compCnt[4] && compCnt[4] <= 1e9 && 0 <= compCnt[5] && compCnt[5] <= 1e9 && 0 <= compCnt[6] && compCnt[6] <= 1e9 ) return 2;
if (0 <= compCnt[0] && compCnt[0] <= 1e9 && 0 <= compCnt[1] && compCnt[1] <= 1e9 && 0 <= compCnt[2] && compCnt[2] <= 1e9 && 0 <= compCnt[3] && compCnt[3] <= 1e9 && 21059 <= compCnt[4] && compCnt[4] <= 1e9 && 5843 <= compCnt[5] && compCnt[5] <= 1e9 && 0 <= compCnt[6] && compCnt[6] <= 1e9 ) return 3;
if (247077 <= compCnt[0] && compCnt[0] <= 1e9 && 0 <= compCnt[1] && compCnt[1] <= 1e9 && 0 <= compCnt[2] && compCnt[2] <= 1e9 && 0 <= compCnt[3] && compCnt[3] <= 1e9 && 87 <= compCnt[4] && compCnt[4] <= 14890 && 0 <= compCnt[5] && compCnt[5] <= 1e9 && 0 <= compCnt[6] && compCnt[6] <= 1e9 ) return 4;
if (0 <= compCnt[0] && compCnt[0] <= 1e9 && 0 <= compCnt[1] && compCnt[1] <= 1e9 && 60263 <= compCnt[2] && compCnt[2] <= 1e9 && 0 <= compCnt[3] && compCnt[3] <= 39193 && 0 <= compCnt[4] && compCnt[4] <= 1e9 && 0 <= compCnt[5] && compCnt[5] <= 4793 && 54 <= compCnt[6] && compCnt[6] <= 1e9 ) return 4;
if (0 <= compCnt[0] && compCnt[0] <= 1e9 && 0 <= compCnt[1] && compCnt[1] <= 1e9 && 0 <= compCnt[2] && compCnt[2] <= 1e9 && 0 <= compCnt[3] && compCnt[3] <= 1e9 && 10227 <= compCnt[4] && compCnt[4] <= 17499 && 0 <= compCnt[5] && compCnt[5] <= 1e9 && 0 <= compCnt[6] && compCnt[6] <= 1e9 ) return 1;
if (0 <= compCnt[0] && compCnt[0] <= 1e9 && 0 <= compCnt[1] && compCnt[1] <= 1e9 && 0 <= compCnt[2] && compCnt[2] <= 1e9 && 38855 <= compCnt[3] && compCnt[3] <= 1e9 && 0 <= compCnt[4] && compCnt[4] <= 1e9 && 0 <= compCnt[5] && compCnt[5] <= 1e9 && 65 <= compCnt[6] && compCnt[6] <= 1e9 ) return 2;
if (0 <= compCnt[0] && compCnt[0] <= 24843 && 0 <= compCnt[1] && compCnt[1] <= 1e9 && 0 <= compCnt[2] && compCnt[2] <= 1e9 && 73070 <= compCnt[3] && compCnt[3] <= 1e9 && 0 <= compCnt[4] && compCnt[4] <= 1e9 && 837 <= compCnt[5] && compCnt[5] <= 1e9 && 0 <= compCnt[6] && compCnt[6] <= 1e9 ) return 2;
if (0 <= compCnt[0] && compCnt[0] <= 55356 && 0 <= compCnt[1] && compCnt[1] <= 1e9 && 22241 <= compCnt[2] && compCnt[2] <= 1e9 && 0 <= compCnt[3] && compCnt[3] <= 1e9 && 0 <= compCnt[4] && compCnt[4] <= 1e9 && 0 <= compCnt[5] && compCnt[5] <= 1e9 && 69 <= compCnt[6] && compCnt[6] <= 1e9 ) return 2;
if (0 <= compCnt[0] && compCnt[0] <= 54135 && 0 <= compCnt[1] && compCnt[1] <= 1e9 && 0 <= compCnt[2] && compCnt[2] <= 1e9 && 0 <= compCnt[3] && compCnt[3] <= 1e9 && 0 <= compCnt[4] && compCnt[4] <= 1e9 && 7105 <= compCnt[5] && compCnt[5] <= 1e9 && 0 <= compCnt[6] && compCnt[6] <= 1e9 ) return 1;
if (0 <= compCnt[0] && compCnt[0] <= 1e9 && 0 <= compCnt[1] && compCnt[1] <= 1e9 && 0 <= compCnt[2] && compCnt[2] <= 1e9 && 0 <= compCnt[3] && compCnt[3] <= 1e9 && 0 <= compCnt[4] && compCnt[4] <= 49132 && 0 <= compCnt[5] && compCnt[5] <= 1e9 && 0 <= compCnt[6] && compCnt[6] <= 44 ) return 3;
if (0 <= compCnt[0] && compCnt[0] <= 1e9 && 0 <= compCnt[1] && compCnt[1] <= 1e9 && 125267 <= compCnt[2] && compCnt[2] <= 1e9 && 0 <= compCnt[3] && compCnt[3] <= 1e9 && 32133 <= compCnt[4] && compCnt[4] <= 1e9 && 0 <= compCnt[5] && compCnt[5] <= 1e9 && 53 <= compCnt[6] && compCnt[6] <= 1e9 ) return 2;
return 3;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
116 ms |
27468 KB |
Output is correct |
2 |
Incorrect |
110 ms |
19980 KB |
Output isn't correct |
3 |
Correct |
109 ms |
22532 KB |
Output is correct |
4 |
Correct |
119 ms |
24404 KB |
Output is correct |
5 |
Correct |
105 ms |
19644 KB |
Output is correct |
6 |
Correct |
121 ms |
31628 KB |
Output is correct |
7 |
Incorrect |
121 ms |
27988 KB |
Output isn't correct |
8 |
Correct |
129 ms |
31588 KB |
Output is correct |
9 |
Correct |
101 ms |
28964 KB |
Output is correct |
10 |
Incorrect |
129 ms |
29388 KB |
Output isn't correct |
11 |
Correct |
128 ms |
31732 KB |
Output is correct |
12 |
Incorrect |
127 ms |
27436 KB |
Output isn't correct |
13 |
Correct |
116 ms |
31392 KB |
Output is correct |
14 |
Incorrect |
130 ms |
28160 KB |
Output isn't correct |
15 |
Incorrect |
100 ms |
20528 KB |
Output isn't correct |
16 |
Correct |
104 ms |
31692 KB |
Output is correct |
17 |
Correct |
122 ms |
27284 KB |
Output is correct |
18 |
Incorrect |
124 ms |
29836 KB |
Output isn't correct |
19 |
Correct |
126 ms |
27240 KB |
Output is correct |
20 |
Correct |
126 ms |
25448 KB |
Output is correct |
21 |
Correct |
113 ms |
28608 KB |
Output is correct |
22 |
Incorrect |
123 ms |
22988 KB |
Output isn't correct |
23 |
Incorrect |
129 ms |
29184 KB |
Output isn't correct |
24 |
Incorrect |
115 ms |
28284 KB |
Output isn't correct |
25 |
Correct |
109 ms |
23788 KB |
Output is correct |
26 |
Correct |
123 ms |
29496 KB |
Output is correct |
27 |
Correct |
150 ms |
30368 KB |
Output is correct |
28 |
Correct |
123 ms |
25512 KB |
Output is correct |
29 |
Correct |
110 ms |
28584 KB |
Output is correct |
30 |
Correct |
114 ms |
26648 KB |
Output is correct |
31 |
Correct |
130 ms |
30444 KB |
Output is correct |
32 |
Correct |
115 ms |
28620 KB |
Output is correct |
33 |
Correct |
107 ms |
22392 KB |
Output is correct |
34 |
Correct |
117 ms |
27812 KB |
Output is correct |
35 |
Correct |
129 ms |
31080 KB |
Output is correct |
36 |
Correct |
121 ms |
30076 KB |
Output is correct |
37 |
Incorrect |
129 ms |
24396 KB |
Output isn't correct |
38 |
Incorrect |
147 ms |
30220 KB |
Output isn't correct |
39 |
Incorrect |
122 ms |
29416 KB |
Output isn't correct |
40 |
Correct |
123 ms |
26684 KB |
Output is correct |
41 |
Incorrect |
121 ms |
28916 KB |
Output isn't correct |
42 |
Incorrect |
118 ms |
24432 KB |
Output isn't correct |
43 |
Incorrect |
107 ms |
26956 KB |
Output isn't correct |
44 |
Correct |
115 ms |
25852 KB |
Output is correct |
45 |
Correct |
124 ms |
31724 KB |
Output is correct |
46 |
Correct |
146 ms |
31580 KB |
Output is correct |
47 |
Correct |
121 ms |
26772 KB |
Output is correct |
48 |
Correct |
112 ms |
21520 KB |
Output is correct |
49 |
Correct |
127 ms |
27468 KB |
Output is correct |
50 |
Correct |
123 ms |
31616 KB |
Output is correct |
51 |
Incorrect |
130 ms |
28680 KB |
Output isn't correct |
52 |
Correct |
128 ms |
30672 KB |
Output is correct |
53 |
Correct |
118 ms |
29656 KB |
Output is correct |
54 |
Incorrect |
106 ms |
26952 KB |
Output isn't correct |
55 |
Incorrect |
128 ms |
26572 KB |
Output isn't correct |
56 |
Correct |
128 ms |
27736 KB |
Output is correct |
57 |
Correct |
114 ms |
21496 KB |
Output is correct |
58 |
Correct |
129 ms |
30376 KB |
Output is correct |
59 |
Correct |
108 ms |
25720 KB |
Output is correct |
60 |
Correct |
106 ms |
31712 KB |
Output is correct |
61 |
Correct |
122 ms |
24900 KB |
Output is correct |
62 |
Correct |
110 ms |
27748 KB |
Output is correct |
63 |
Incorrect |
119 ms |
28552 KB |
Output isn't correct |
64 |
Correct |
137 ms |
31408 KB |
Output is correct |
65 |
Correct |
128 ms |
29788 KB |
Output is correct |
66 |
Correct |
154 ms |
28988 KB |
Output is correct |
67 |
Incorrect |
116 ms |
27520 KB |
Output isn't correct |
68 |
Incorrect |
134 ms |
27932 KB |
Output isn't correct |
69 |
Correct |
130 ms |
31740 KB |
Output is correct |
70 |
Incorrect |
121 ms |
26524 KB |
Output isn't correct |
71 |
Incorrect |
126 ms |
28080 KB |
Output isn't correct |
72 |
Correct |
132 ms |
28380 KB |
Output is correct |
73 |
Incorrect |
131 ms |
23712 KB |
Output isn't correct |
74 |
Correct |
130 ms |
21740 KB |
Output is correct |
75 |
Correct |
135 ms |
31616 KB |
Output is correct |
76 |
Correct |
130 ms |
29960 KB |
Output is correct |
77 |
Correct |
121 ms |
25244 KB |
Output is correct |
78 |
Incorrect |
124 ms |
29720 KB |
Output isn't correct |
79 |
Incorrect |
125 ms |
24900 KB |
Output isn't correct |
80 |
Correct |
140 ms |
32064 KB |
Output is correct |
81 |
Incorrect |
124 ms |
29892 KB |
Output isn't correct |
82 |
Correct |
126 ms |
27696 KB |
Output is correct |
83 |
Correct |
117 ms |
31308 KB |
Output is correct |
84 |
Incorrect |
132 ms |
27740 KB |
Output isn't correct |
85 |
Correct |
139 ms |
26316 KB |
Output is correct |
86 |
Incorrect |
113 ms |
31852 KB |
Output isn't correct |
87 |
Correct |
134 ms |
23864 KB |
Output is correct |
88 |
Correct |
127 ms |
25444 KB |
Output is correct |
89 |
Correct |
103 ms |
21864 KB |
Output is correct |
90 |
Correct |
130 ms |
30732 KB |
Output is correct |
91 |
Correct |
108 ms |
21840 KB |
Output is correct |
92 |
Correct |
141 ms |
30212 KB |
Output is correct |
93 |
Incorrect |
116 ms |
26444 KB |
Output isn't correct |
94 |
Incorrect |
122 ms |
27612 KB |
Output isn't correct |
95 |
Correct |
145 ms |
31724 KB |
Output is correct |
96 |
Incorrect |
135 ms |
27272 KB |
Output isn't correct |
97 |
Correct |
108 ms |
27820 KB |
Output is correct |
98 |
Correct |
113 ms |
29664 KB |
Output is correct |
99 |
Correct |
121 ms |
31772 KB |
Output is correct |
100 |
Correct |
124 ms |
24388 KB |
Output is correct |
101 |
Correct |
104 ms |
31732 KB |
Output is correct |
102 |
Correct |
124 ms |
30668 KB |
Output is correct |