제출 #840795

#제출 시각아이디문제언어결과실행 시간메모리
840795ogkostya축구 경기장 (IOI23_soccer)C++17
6 / 100
265 ms31628 KiB
#include "soccer.h"


int GoTo(std::vector<std::vector<bool>>& V, std::vector<std::vector<int>>& F, int i, int j, int dx1, int dx2, int dy1, int dy2, int N)
{
    int count = 0;

    int x1 = i, y1 = j;
    while (true)
    {
        x1 += dx1;
        y1 += dy1;

        if (x1 < 0 || x1 >= N)
            break;
        if (y1 < 0 || y1 >= N)
            break;

        if (F[x1][y1] == 1)
        {
            break;
        }
        if (!V[x1][y1])
        {
            V[x1][y1] = true;
            count++;
        }

        int x2 = x1;
        int y2 = y1;
        while (true)
        {
            x2 += dx2;
            y2 += dy2;

            if (x2 < 0 || x2 >= N)
                break;
            if (y2 < 0 || y2 >= N)
                break;

            if (F[x2][y2] == 1)
            {
                break;
            }
            if (!V[x2][y2])
            {
                V[x2][y2] = true;
                count++;
            }
        }
    }

    return count;
}

int biggest_stadium(int N, std::vector<std::vector<int>> F)
{
    int x, y;
    int c = 0;

    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            if (F[i][j] == 1)
            {
                c++;
                x = i;
                y = j;
            }
        }
    }

    if (c == 1)
    {
        return std::max(std::max(N * N - (x + 1) * (y + 1), N * N - (N - x) * (y + 1)), std::max(N * N - (x + 1) * (N - y), N * N - (N - x) * (N - y)));
    }

    std::vector<std::vector<int>> S(N, std::vector<int>(N));
    bool allmax = true;
    if (N <= 7)
    {

        for (int i = 0; i < N; i++)
        {
            for (int j = 0; j < N; j++)
            {
                if (F[i][j] == 0)
                {
                    std::vector<std::vector<bool>> V(N, std::vector<bool>(N));
                    int count = 1;

                    count += GoTo(V, F, i, j, 1, 0, 0, 1, N);
                    count += GoTo(V, F, i, j, 1, 0, 0, -1, N);

                    count += GoTo(V, F, i, j, -1, 0, 0, 1, N);
                    count += GoTo(V, F, i, j, -1, 0, 0, -1, N);

                    count += GoTo(V, F, i, j, 0, 1, 1, 0, N);
                    count += GoTo(V, F, i, j, 0, 1, -1, 0, N);

                    count += GoTo(V, F, i, j, 0, -1, 1, 0, N);
                    count += GoTo(V, F, i, j, 0, -1, -1, 0, N);

                    S[i][j] = count;

                    if (count != c)
                    {
                        allmax = false;
                    }
                }
            }
        }
    }

    return allmax ? c : 1;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...