#include "soccer.h"
using namespace std;
#include <bits/stdc++.h>
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
// rectangle lol
struct Square
{
int x1, y1, x2, y2;
};
typedef vector<Square> vSq;
#define loop(x, i) for (int i = 0; i < x; i++)
int n;
vvi f;
inline bool getF(int x, int y)
{
if (x >= n || y >= n || x < 0 || y < 0)
return 1;
return f[x][y] == 1;
}
int extendSquare(Square sq)
{
vi extensUp(n), extensDown(n), extensRight(n), extensLeft(n);
int bestVert = 0, bestHorz = 0;
for (int x = sq.x1; x <= sq.x2; x++)
{
int up = 0;
int down = 0;
while (getF(x, sq.y1 + up + 1) == 0)
{
up++;
}
while (getF(x, sq.y2 - down - 1) == 0)
{
down++;
}
extensUp[x] = up;
extensUp[x] = down;
}
// i = hoogtepunt
for (int i = sq.x1; i <= sq.x2; i++)
{
if (getF(i, sq.y1) == 1)
continue;
}
return (sq.x2 - sq.x1 + 1) * (sq.y2 - sq.y1 + 1);
}
int biggest_stadium(int N, vvi F)
{
n = N;
f = F;
/* vvii freeSpaces(N, {0, 0});
loop(N, x)
{
loop(N, y)
{
if (F[x][y] == 0)
{
freeSpaces[x].back().second++;
}
else
{
freeSpaces[x].push_back({y, 0});
}
}
}*/
int best = 1;
loop(N, x1)
{
loop(N, y1)
{
if (F[x1][y1])
continue;
int maxX = x1;
while (getF(maxX + 1, y1) == 0)
{
maxX++;
}
for (int dx = maxX; dx >= 0; dx--)
{
int h = 1;
while (true)
{
bool posi = true;
// check if this height is possible
int i = 0;
for (; i <= dx; i++)
{
if (getF(x1 + i, y1 + h))
{
posi = false;
break;
}
}
if (!posi)
break;
h++;
}
h--;
int s = extendSquare({x1, y1, x1 + dx, y1 + h});
if (s > best)
{
best = s;
}
}
}
}
return best;
}
Compilation message
soccer.cpp: In function 'int extendSquare(Square)':
soccer.cpp:34:9: warning: unused variable 'bestVert' [-Wunused-variable]
34 | int bestVert = 0, bestHorz = 0;
| ^~~~~~~~
soccer.cpp:34:23: warning: unused variable 'bestHorz' [-Wunused-variable]
34 | int bestVert = 0, bestHorz = 0;
| ^~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
500 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
wrong |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
wrong |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
500 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
500 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
500 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
500 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |