이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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)));
}
c = N * N - c;
std::vector<std::vector<int>> S(N, std::vector<int>(N));
bool allmax = true;
if (N <= 30)
{
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 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... |