Submission #768627

# Submission time Handle Problem Language Result Execution time Memory
768627 2023-06-28T10:10:53 Z boris_mihov Art Class (IOI13_artclass) C++17
0 / 100
159 ms 32168 KB
#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);
                }
            }
        }
    }

    for (int i = 0 ; i < CNTBASE ; ++i)
    {
        std::cout << compCnt[i] << ' ';
    }

    std::cout << '\n';
    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;
}
# Verdict Execution time Memory Grader output
1 Incorrect 113 ms 31820 KB Output isn't correct
2 Incorrect 115 ms 31700 KB Output isn't correct
3 Incorrect 123 ms 27488 KB Output isn't correct
4 Incorrect 127 ms 31764 KB Output isn't correct
5 Incorrect 132 ms 31704 KB Output isn't correct
6 Incorrect 126 ms 27284 KB Output isn't correct
7 Incorrect 131 ms 27552 KB Output isn't correct
8 Incorrect 114 ms 28904 KB Output isn't correct
9 Incorrect 125 ms 29528 KB Output isn't correct
10 Incorrect 120 ms 26656 KB Output isn't correct
11 Incorrect 117 ms 27832 KB Output isn't correct
12 Incorrect 115 ms 28652 KB Output isn't correct
13 Incorrect 114 ms 31316 KB Output isn't correct
14 Incorrect 126 ms 31568 KB Output isn't correct
15 Incorrect 118 ms 27208 KB Output isn't correct
16 Incorrect 144 ms 31572 KB Output isn't correct
17 Incorrect 125 ms 25448 KB Output isn't correct
18 Incorrect 124 ms 29660 KB Output isn't correct
19 Incorrect 136 ms 23620 KB Output isn't correct
20 Incorrect 141 ms 30056 KB Output isn't correct
21 Incorrect 138 ms 31672 KB Output isn't correct
22 Incorrect 125 ms 27836 KB Output isn't correct
23 Incorrect 142 ms 30688 KB Output isn't correct
24 Incorrect 123 ms 21476 KB Output isn't correct
25 Incorrect 117 ms 29340 KB Output isn't correct
26 Incorrect 121 ms 21960 KB Output isn't correct
27 Incorrect 112 ms 29644 KB Output isn't correct
28 Incorrect 126 ms 28452 KB Output isn't correct
29 Incorrect 122 ms 26488 KB Output isn't correct
30 Incorrect 129 ms 29848 KB Output isn't correct
31 Incorrect 125 ms 23148 KB Output isn't correct
32 Incorrect 114 ms 25856 KB Output isn't correct
33 Incorrect 118 ms 28572 KB Output isn't correct
34 Incorrect 128 ms 28920 KB Output isn't correct
35 Incorrect 132 ms 27460 KB Output isn't correct
36 Incorrect 156 ms 29828 KB Output isn't correct
37 Incorrect 106 ms 19636 KB Output isn't correct
38 Incorrect 125 ms 29928 KB Output isn't correct
39 Incorrect 112 ms 20504 KB Output isn't correct
40 Incorrect 159 ms 27340 KB Output isn't correct
41 Incorrect 127 ms 29340 KB Output isn't correct
42 Incorrect 148 ms 31720 KB Output isn't correct
43 Incorrect 114 ms 26956 KB Output isn't correct
44 Incorrect 133 ms 30796 KB Output isn't correct
45 Incorrect 136 ms 30400 KB Output isn't correct
46 Incorrect 120 ms 24428 KB Output isn't correct
47 Incorrect 107 ms 22464 KB Output isn't correct
48 Incorrect 120 ms 21692 KB Output isn't correct
49 Incorrect 124 ms 28992 KB Output isn't correct
50 Incorrect 113 ms 31608 KB Output isn't correct
51 Incorrect 143 ms 26440 KB Output isn't correct
52 Incorrect 124 ms 31560 KB Output isn't correct
53 Incorrect 125 ms 27852 KB Output isn't correct
54 Incorrect 115 ms 27792 KB Output isn't correct
55 Incorrect 126 ms 25496 KB Output isn't correct
56 Incorrect 121 ms 28340 KB Output isn't correct
57 Incorrect 130 ms 27236 KB Output isn't correct
58 Incorrect 139 ms 31488 KB Output isn't correct
59 Incorrect 122 ms 24304 KB Output isn't correct
60 Incorrect 125 ms 29812 KB Output isn't correct
61 Incorrect 114 ms 25676 KB Output isn't correct
62 Incorrect 136 ms 28116 KB Output isn't correct
63 Incorrect 149 ms 29852 KB Output isn't correct
64 Incorrect 127 ms 28184 KB Output isn't correct
65 Incorrect 131 ms 28560 KB Output isn't correct
66 Incorrect 124 ms 27540 KB Output isn't correct
67 Incorrect 117 ms 24344 KB Output isn't correct
68 Incorrect 105 ms 23756 KB Output isn't correct
69 Incorrect 133 ms 27748 KB Output isn't correct
70 Incorrect 116 ms 21484 KB Output isn't correct
71 Incorrect 116 ms 20044 KB Output isn't correct
72 Incorrect 129 ms 30392 KB Output isn't correct
73 Incorrect 123 ms 31636 KB Output isn't correct
74 Incorrect 140 ms 30284 KB Output isn't correct
75 Incorrect 126 ms 26260 KB Output isn't correct
76 Incorrect 126 ms 25264 KB Output isn't correct
77 Incorrect 155 ms 31096 KB Output isn't correct
78 Incorrect 120 ms 26784 KB Output isn't correct
79 Incorrect 134 ms 31620 KB Output isn't correct
80 Incorrect 133 ms 26572 KB Output isn't correct
81 Incorrect 123 ms 27932 KB Output isn't correct
82 Incorrect 108 ms 22524 KB Output isn't correct
83 Incorrect 131 ms 32168 KB Output isn't correct
84 Incorrect 125 ms 27464 KB Output isn't correct
85 Incorrect 128 ms 31724 KB Output isn't correct
86 Incorrect 113 ms 31720 KB Output isn't correct
87 Incorrect 127 ms 29236 KB Output isn't correct
88 Incorrect 117 ms 26960 KB Output isn't correct
89 Incorrect 116 ms 24916 KB Output isn't correct
90 Incorrect 130 ms 31424 KB Output isn't correct
91 Incorrect 120 ms 28664 KB Output isn't correct
92 Incorrect 125 ms 26692 KB Output isn't correct
93 Incorrect 106 ms 21860 KB Output isn't correct
94 Incorrect 136 ms 30176 KB Output isn't correct
95 Incorrect 125 ms 24776 KB Output isn't correct
96 Incorrect 131 ms 23852 KB Output isn't correct
97 Incorrect 114 ms 24448 KB Output isn't correct
98 Incorrect 130 ms 30292 KB Output isn't correct
99 Incorrect 112 ms 25556 KB Output isn't correct
100 Incorrect 110 ms 28492 KB Output isn't correct
101 Incorrect 116 ms 27852 KB Output isn't correct
102 Incorrect 131 ms 30700 KB Output isn't correct