Submission #1018283

#TimeUsernameProblemLanguageResultExecution timeMemory
1018283tmarcinkevicius축구 경기장 (IOI23_soccer)C++17
3.50 / 100
186 ms39504 KiB
#include "soccer.h"
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
#define f first
#define s second

int biggest_stadium(int N, vector<vector<int>> F)
{
    pii minRow, maxRow;
    bool possible = true;
    int state = 0;
    int fullCount = 0;
    pii prev;

    for (int i = 0; i < N; i++)
    {
        int start = N;
        int end = 0;
        int openCount = 0;
        for (int j = 0; j < N; j++)
        {
            if (F[i][j] == 0)
            {
                fullCount++;
                if (openCount == 0)
                {
                    openCount++;
                }
                else if (openCount == 2)
                {
                    openCount++;
                    break;
                }
                start = min(start, j);
                end = max(end, j);
            }
            else
            {
                if (openCount == 1)
                {
                    openCount++;
                }
            }
        }

        //cout << "i = " << i << ", {" << start << ", " << end << "}, cnt = " << openCount << '\n';

        if (openCount >= 3)
        {
            possible = false;
        }

        if (i == 0)
        {
            minRow = {start, end};
            maxRow = {start, end};

            prev = {start, end};
            continue;
        }

        // cout << "min: {" << minRow.f << ", " << minRow.s << "}, max: {" << maxRow.f << ", " << maxRow.s << "}\n";

        if (state == 0 && start <= maxRow.f && end >= maxRow.s)
        {
            maxRow = {start, end};

            prev = {start, end};
            continue;
        }
        else if (start >= prev.f && end <= prev.s && ((start >= minRow.f && end <= minRow.s) || (start <= minRow.f && end >= minRow.s)))
        {
            state = 1;
            minRow = {max(minRow.f, start), min(minRow.s, end)};

            prev = {start, end};
            continue;
        }

        possible = false;
        break;
    }

    if (possible)
    {
        return fullCount;
    }
    else
    {
        return 0;
    }
}

// int main()
// {
//     int count = 0;
//     for (int num = 0; num < (1 << 25); num++)
//     {
//         vector<vector<int>> vec(5);
//         bitset<25> bSet(num);

//         for (int i = 0; i < 5; i++)
//         {
//             vec[i] = vector<int>(5);
//             for (int j = 0; j < 5; j++)
//             {
//                 vec[i][j] = bSet[5 * i + j];
//             }
//         }

//         int res = biggest_stadium(5, vec);

//         if (res)
//         {
//             cout << "\nfound: " << count << '\n';
//             count++;
//             for (int i = 0; i < 5; i++)
//             {
//                 for (int j = 0; j < 5; j++)
//                 {
//                     cout << vec[i][j];
//                 }
//                 cout << '\n';
//             }
//         }
//     }
// }
#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...