#include "soccer.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1000000000;
ll n, m, q, k, x, y, a, b, c, d;
vector< vector<int> > v;
bool check(ll x, ll y) {
if (x < 0 || x >= n) {
return 0;
}
if (y < 0 || y >= n) {
return 0;
}
if (v[x][y]) {
return 0;
}
return 1;
}
int biggest_stadium(int N, std::vector<std::vector<int>> F) {
n = N;
v = F;
ll trees = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (v[i][j]) {
trees++;
}
}
}
int mnx = INF, mny = INF, mxx = -INF, mxy = -INF;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (v[i][j] && ((check(i, j + 1) && check(i, j - 1)) || (check(i + 1, j) && check(i - 1, j)))) {
return 0;
}
if (!v[i][j]) {
mnx = min(mnx, i);
mxx = max(mxx, i);
mny = min(mny, j);
mxy = max(mxy, j);
}
}
}
pair<int, int> mnxr = {INF, -INF};
pair<int, int> mnyr = {INF, -INF};
pair<int, int> mxxr = {INF, -INF};
pair<int, int> mxyr = {INF, -INF};
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (i == mnx) {
mnxr = {min(mnxr.first, j), max(mnxr.second, j)};
}
if (j == mny) {
mnyr = {min(mnyr.first, i), max(mnyr.second, i)};
}
if (i == mxx) {
mxxr = {min(mxxr.first, j), max(mxxr.second, j)};
}
if (j == mxy) {
mxyr = {min(mxyr.first, i), max(mxyr.second, i)};
}
}
}
if (max(mnxr.second, mxxr.second) - min(mnxr.first, mxxr.first) > max(mnxr.second - mnxr.first, mxxr.second - mxxr.first)) {
return 0;
}
if (max(mnyr.second, mxyr.second) - min(mnyr.first, mxyr.first) > max(mnyr.second - mnyr.first, mxyr.second - mxyr.first)) {
return 0;
}
return n * n - trees;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
0 ms |
344 KB |
partial |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
ok |
2 |
Correct |
0 ms |
348 KB |
ok |
3 |
Correct |
0 ms |
348 KB |
ok |
4 |
Correct |
0 ms |
348 KB |
ok |
5 |
Correct |
0 ms |
348 KB |
ok |
6 |
Partially correct |
0 ms |
348 KB |
partial |
7 |
Partially correct |
0 ms |
348 KB |
partial |
8 |
Partially correct |
13 ms |
3224 KB |
partial |
9 |
Partially correct |
180 ms |
47388 KB |
partial |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
ok |
2 |
Correct |
0 ms |
348 KB |
ok |
3 |
Partially correct |
0 ms |
348 KB |
partial |
4 |
Partially correct |
0 ms |
348 KB |
partial |
5 |
Incorrect |
0 ms |
348 KB |
wrong |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
0 ms |
344 KB |
partial |
2 |
Correct |
0 ms |
344 KB |
ok |
3 |
Correct |
0 ms |
348 KB |
ok |
4 |
Partially correct |
0 ms |
348 KB |
partial |
5 |
Partially correct |
0 ms |
348 KB |
partial |
6 |
Incorrect |
0 ms |
348 KB |
wrong |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
0 ms |
344 KB |
partial |
2 |
Correct |
0 ms |
344 KB |
ok |
3 |
Correct |
0 ms |
348 KB |
ok |
4 |
Correct |
0 ms |
348 KB |
ok |
5 |
Correct |
0 ms |
348 KB |
ok |
6 |
Partially correct |
0 ms |
348 KB |
partial |
7 |
Partially correct |
0 ms |
348 KB |
partial |
8 |
Incorrect |
0 ms |
348 KB |
wrong |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
0 ms |
344 KB |
partial |
2 |
Correct |
0 ms |
344 KB |
ok |
3 |
Correct |
0 ms |
348 KB |
ok |
4 |
Correct |
0 ms |
348 KB |
ok |
5 |
Correct |
0 ms |
348 KB |
ok |
6 |
Partially correct |
0 ms |
348 KB |
partial |
7 |
Partially correct |
0 ms |
348 KB |
partial |
8 |
Incorrect |
0 ms |
348 KB |
wrong |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
0 ms |
344 KB |
partial |
2 |
Correct |
0 ms |
344 KB |
ok |
3 |
Correct |
0 ms |
348 KB |
ok |
4 |
Correct |
0 ms |
348 KB |
ok |
5 |
Correct |
0 ms |
348 KB |
ok |
6 |
Correct |
0 ms |
348 KB |
ok |
7 |
Partially correct |
0 ms |
348 KB |
partial |
8 |
Partially correct |
0 ms |
348 KB |
partial |
9 |
Partially correct |
13 ms |
3224 KB |
partial |
10 |
Partially correct |
180 ms |
47388 KB |
partial |
11 |
Partially correct |
0 ms |
348 KB |
partial |
12 |
Partially correct |
0 ms |
348 KB |
partial |
13 |
Incorrect |
0 ms |
348 KB |
wrong |
14 |
Halted |
0 ms |
0 KB |
- |