제출 #1024861

#제출 시각아이디문제언어결과실행 시간메모리
1024861Svizel_pritula축구 경기장 (IOI23_soccer)C++17
25 / 100
233 ms55452 KiB
#include <bits/stdc++.h>

#include "soccer.h"

struct width_pair
{
    int bottom;
    int top;
};

bool is_diamond(int size, std::vector<std::vector<int>> forest)
{
    std::vector<width_pair> widths;

    for (int x = 0; x < size; x++)
    {
        width_pair width = {size, -1};

        for (int y = 0; y < size; y++)
        {
            if (forest[x][y] == 0)
            {
                width.bottom = y;
                break;
            }
        }

        for (int y = size - 1; y >= 0; y--)
        {
            if (forest[x][y] == 0)
            {
                width.top = y;
                break;
            }
        }

        for (int y = width.bottom; y <= width.top; y++)
            if (forest[x][y])
                return false;

        widths.push_back(width);
    }

    width_pair last = widths.front();
    bool is_after_change = false;

    for (int i = 0; i < widths.size(); i++)
    {
        width_pair current = widths[i];

        if (current.bottom > last.bottom || current.top < last.top)
            is_after_change = true;

        if (is_after_change)
            for (int j = 0; j < i; j++)
            {
                width_pair past = widths[j];

                if (past.top >= current.top && past.bottom <= current.bottom)
                    continue;

                if (past.top <= current.top && past.bottom >= current.bottom)
                    continue;

                return false;
            }

        last = current;
    }

    return true;
}

int biggest_stadium(int size, std::vector<std::vector<int>> forest)
{
    int empty = 0;

    for (int x = 0; x < size; x++)
        for (int y = 0; y < size; y++)
            empty += forest[x][y] == 0;

    if (!is_diamond(size, forest))
        return 0;

    for (int x = 0; x < size; x++)
        for (int y = 0; y < x; y++)
            std::swap(forest[x][y], forest[y][x]);

    if (!is_diamond(size, forest))
        return 0;

    return empty;
}

컴파일 시 표준 에러 (stderr) 메시지

soccer.cpp: In function 'bool is_diamond(int, std::vector<std::vector<int> >)':
soccer.cpp:47:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<width_pair>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |     for (int i = 0; i < widths.size(); i++)
      |                     ~~^~~~~~~~~~~~~~~
#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...