# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1024861 | Svizel_pritula | Soccer Stadium (IOI23_soccer) | C++17 | 233 ms | 55452 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |