#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;
ll mx = n * n;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (v[i][j]) {
trees++;
mx = min(mx, max({n * n - (i + 1) * (j + 1), n * n - (i + 1) * (n - j), n * n - (n - i) * (j + 1), n * n - (n - i) * (n - j)}));
}
}
}
if (trees <= 1) {
return mx;
}
if (n <= 3) {
ll ans = 0;
for (int _ = 0; _ < (1 << (n * n)); _++) {
vector< vector<ll> > mat(n, vector<ll>(n));
vector< pair<ll, ll> > vp;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if ((_ >> (i * n + j)) & 1) {
mat[i][j] = 1;
vp.push_back({i, j});
}
}
}
bool fl = 1;
for (int i = 0; i < vp.size(); i++) {
if (v[vp[i].first][vp[i].second]) {
fl = 0;
break;
}
for (int j = i + 1; j < vp.size(); j++) {
bool fl1 = 1, fl2 = 1;
for (int i1 = min(vp[i].second, vp[j].second); i1 <= max(vp[i].second, vp[j].second); i1++) {
fl1 &= mat[vp[i].first][i1];
}
for (int i1 = min(vp[i].first, vp[j].first); i1 <= max(vp[i].first, vp[j].first); i1++) {
fl1 &= mat[i1][vp[j].second];
}
for (int i1 = min(vp[i].second, vp[j].second); i1 <= max(vp[i].second, vp[j].second); i1++) {
fl2 &= mat[vp[j].first][i1];
}
for (int i1 = min(vp[i].first, vp[j].first); i1 <= max(vp[i].first, vp[j].first); i1++) {
fl2 &= mat[i1][vp[i].second];
}
// if (!(mat[vp[i].first][vp[j].second] || mat[vp[j].first][vp[i].second])) {
// fl = 0;
// }
fl &= (fl1 | fl2);
}
}
if (fl) {
ans = max(ans, (ll)vp.size());
}
}
return ans;
}
ll ans = 0;
vector< pair<ll, ll> > vp;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (!v[i][j]) {
vp.push_back({i, j});
}
}
}
bool fl = 1;
for (int i = 0; i < vp.size(); i++) {
for (int j = i + 1; j < vp.size(); j++) {
bool fl1 = 1, fl2 = 1;
for (int i1 = min(vp[i].second, vp[j].second); i1 <= max(vp[i].second, vp[j].second); i1++) {
fl1 &= !v[vp[i].first][i1];
}
for (int i1 = min(vp[i].first, vp[j].first); i1 <= max(vp[i].first, vp[j].first); i1++) {
fl1 &= !v[i1][vp[j].second];
}
for (int i1 = min(vp[i].second, vp[j].second); i1 <= max(vp[i].second, vp[j].second); i1++) {
fl2 &= !v[vp[j].first][i1];
}
for (int i1 = min(vp[i].first, vp[j].first); i1 <= max(vp[i].first, vp[j].first); i1++) {
fl2 &= !v[i1][vp[i].second];
}
// if (!(mat[vp[i].first][vp[j].second] || mat[vp[j].first][vp[i].second])) {
// fl = 0;
// }
fl &= (fl1 | fl2);
}
}
if (fl) {
ans = max(ans, (ll)vp.size());
}
return ans;
// int mnx = INF, mny = INF, mxx = -INF, mxy = -INF;
// vector< vector<ll> > vec(n);
// vector< pair<ll, ll> > vp(n);
// 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);
// vec[i].push_back(j);
// }
// }
// }
// for (int i = 1; i < n - 1; i++) {
// if (vec[i].size() == 0 && vec[i - 1].size() > 0 && vec[i + 1].size() > 0) {
// return 0;
// }
// }
// for (int i = 0; i < n; i++) {
// for (int j = 1; j < vec[i].size(); j++) {
// if (vec[i][j - 1] + 1 != vec[i][j]) {
// return 0;
// }
// }
// if (vec[i].size() == 0) {
// vp[i] = {INF, -INF};
// }
// else {
// vp[i] = {vec[i][0], vec[i][vec[i].size() - 1]};
// }
// // cout << vp[i].first << ' ' << vp[i].second << '\n';
// }
// bool fl = 0;
// for (int i = 1; i < n; i++) {
// if (fl == 0) {
// if (!(vp[i].first <= vp[i - 1].first && vp[i].second >= vp[i - 1].second)) {
// fl = 1;
// }
// }
// else {
// if (!(vp[i].first >= vp[i - 1].first && vp[i].second <= vp[i - 1].second)) {
// return 0;
// }
// }
// }
// 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 (v[i][j]) {
// continue;
// }
// 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)};
// }
// }
// }
// // cout << mnxr.first << ' ' << mnxr.second << '\n';
// // cout << mxxr.first << ' ' << mxxr.second << '\n';
// // cout << mnyr.first << ' ' << mnyr.second << '\n';
// // cout << mxyr.first << ' ' << mxyr.second << '\n';
// 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;
}
Compilation message
soccer.cpp: In function 'int biggest_stadium(int, std::vector<std::vector<int> >)':
soccer.cpp:55:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
55 | for (int i = 0; i < vp.size(); i++) {
| ~~^~~~~~~~~~~
soccer.cpp:60:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
60 | for (int j = i + 1; j < vp.size(); j++) {
| ~~^~~~~~~~~~~
soccer.cpp:96:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
96 | for (int i = 0; i < vp.size(); i++) {
| ~~^~~~~~~~~~~
soccer.cpp:97:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
97 | for (int j = i + 1; j < vp.size(); j++) {
| ~~^~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
0 ms |
348 KB |
partial |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
ok |
2 |
Correct |
0 ms |
348 KB |
ok |
3 |
Correct |
1 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 |
Correct |
1 ms |
348 KB |
ok |
8 |
Correct |
10 ms |
3232 KB |
ok |
9 |
Correct |
165 ms |
47444 KB |
ok |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
ok |
2 |
Correct |
0 ms |
348 KB |
ok |
3 |
Correct |
0 ms |
348 KB |
ok |
4 |
Correct |
1 ms |
348 KB |
ok |
5 |
Correct |
0 ms |
344 KB |
ok |
6 |
Correct |
0 ms |
348 KB |
ok |
7 |
Correct |
0 ms |
348 KB |
ok |
8 |
Correct |
0 ms |
348 KB |
ok |
9 |
Correct |
0 ms |
348 KB |
ok |
10 |
Correct |
0 ms |
348 KB |
ok |
11 |
Correct |
0 ms |
348 KB |
ok |
12 |
Correct |
0 ms |
348 KB |
ok |
13 |
Correct |
0 ms |
348 KB |
ok |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
0 ms |
348 KB |
partial |
2 |
Correct |
0 ms |
348 KB |
ok |
3 |
Correct |
0 ms |
348 KB |
ok |
4 |
Correct |
0 ms |
348 KB |
ok |
5 |
Correct |
1 ms |
348 KB |
ok |
6 |
Correct |
0 ms |
344 KB |
ok |
7 |
Correct |
0 ms |
348 KB |
ok |
8 |
Correct |
0 ms |
348 KB |
ok |
9 |
Correct |
0 ms |
348 KB |
ok |
10 |
Correct |
0 ms |
348 KB |
ok |
11 |
Correct |
0 ms |
348 KB |
ok |
12 |
Correct |
0 ms |
348 KB |
ok |
13 |
Correct |
0 ms |
348 KB |
ok |
14 |
Correct |
0 ms |
348 KB |
ok |
15 |
Partially correct |
0 ms |
344 KB |
partial |
16 |
Partially correct |
0 ms |
348 KB |
partial |
17 |
Partially correct |
0 ms |
348 KB |
partial |
18 |
Partially correct |
0 ms |
348 KB |
partial |
19 |
Partially correct |
1 ms |
348 KB |
partial |
20 |
Correct |
0 ms |
348 KB |
ok |
21 |
Correct |
0 ms |
348 KB |
ok |
22 |
Partially correct |
0 ms |
344 KB |
partial |
23 |
Partially correct |
0 ms |
348 KB |
partial |
24 |
Partially correct |
1 ms |
348 KB |
partial |
25 |
Partially correct |
0 ms |
348 KB |
partial |
26 |
Partially correct |
0 ms |
348 KB |
partial |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
0 ms |
348 KB |
partial |
2 |
Correct |
0 ms |
348 KB |
ok |
3 |
Correct |
0 ms |
348 KB |
ok |
4 |
Correct |
1 ms |
348 KB |
ok |
5 |
Correct |
0 ms |
348 KB |
ok |
6 |
Correct |
0 ms |
348 KB |
ok |
7 |
Correct |
1 ms |
348 KB |
ok |
8 |
Correct |
0 ms |
344 KB |
ok |
9 |
Correct |
0 ms |
348 KB |
ok |
10 |
Correct |
0 ms |
348 KB |
ok |
11 |
Correct |
0 ms |
348 KB |
ok |
12 |
Correct |
0 ms |
348 KB |
ok |
13 |
Correct |
0 ms |
348 KB |
ok |
14 |
Correct |
0 ms |
348 KB |
ok |
15 |
Correct |
0 ms |
348 KB |
ok |
16 |
Correct |
0 ms |
348 KB |
ok |
17 |
Partially correct |
0 ms |
344 KB |
partial |
18 |
Partially correct |
0 ms |
348 KB |
partial |
19 |
Partially correct |
0 ms |
348 KB |
partial |
20 |
Partially correct |
0 ms |
348 KB |
partial |
21 |
Partially correct |
1 ms |
348 KB |
partial |
22 |
Correct |
0 ms |
348 KB |
ok |
23 |
Correct |
0 ms |
348 KB |
ok |
24 |
Partially correct |
0 ms |
344 KB |
partial |
25 |
Partially correct |
0 ms |
348 KB |
partial |
26 |
Partially correct |
1 ms |
348 KB |
partial |
27 |
Partially correct |
0 ms |
348 KB |
partial |
28 |
Partially correct |
0 ms |
348 KB |
partial |
29 |
Partially correct |
0 ms |
348 KB |
partial |
30 |
Partially correct |
11 ms |
472 KB |
partial |
31 |
Partially correct |
10 ms |
348 KB |
partial |
32 |
Partially correct |
4 ms |
348 KB |
partial |
33 |
Partially correct |
0 ms |
348 KB |
partial |
34 |
Correct |
1 ms |
344 KB |
ok |
35 |
Correct |
1 ms |
348 KB |
ok |
36 |
Partially correct |
1 ms |
348 KB |
partial |
37 |
Partially correct |
0 ms |
348 KB |
partial |
38 |
Partially correct |
1 ms |
344 KB |
partial |
39 |
Partially correct |
1 ms |
348 KB |
partial |
40 |
Partially correct |
5 ms |
348 KB |
partial |
41 |
Partially correct |
11 ms |
344 KB |
partial |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
0 ms |
348 KB |
partial |
2 |
Correct |
0 ms |
348 KB |
ok |
3 |
Correct |
0 ms |
348 KB |
ok |
4 |
Correct |
1 ms |
348 KB |
ok |
5 |
Correct |
0 ms |
348 KB |
ok |
6 |
Correct |
0 ms |
348 KB |
ok |
7 |
Correct |
1 ms |
348 KB |
ok |
8 |
Correct |
0 ms |
344 KB |
ok |
9 |
Correct |
0 ms |
348 KB |
ok |
10 |
Correct |
0 ms |
348 KB |
ok |
11 |
Correct |
0 ms |
348 KB |
ok |
12 |
Correct |
0 ms |
348 KB |
ok |
13 |
Correct |
0 ms |
348 KB |
ok |
14 |
Correct |
0 ms |
348 KB |
ok |
15 |
Correct |
0 ms |
348 KB |
ok |
16 |
Correct |
0 ms |
348 KB |
ok |
17 |
Partially correct |
0 ms |
344 KB |
partial |
18 |
Partially correct |
0 ms |
348 KB |
partial |
19 |
Partially correct |
0 ms |
348 KB |
partial |
20 |
Partially correct |
0 ms |
348 KB |
partial |
21 |
Partially correct |
1 ms |
348 KB |
partial |
22 |
Correct |
0 ms |
348 KB |
ok |
23 |
Correct |
0 ms |
348 KB |
ok |
24 |
Partially correct |
0 ms |
344 KB |
partial |
25 |
Partially correct |
0 ms |
348 KB |
partial |
26 |
Partially correct |
1 ms |
348 KB |
partial |
27 |
Partially correct |
0 ms |
348 KB |
partial |
28 |
Partially correct |
0 ms |
348 KB |
partial |
29 |
Partially correct |
0 ms |
348 KB |
partial |
30 |
Partially correct |
11 ms |
472 KB |
partial |
31 |
Partially correct |
10 ms |
348 KB |
partial |
32 |
Partially correct |
4 ms |
348 KB |
partial |
33 |
Partially correct |
0 ms |
348 KB |
partial |
34 |
Correct |
1 ms |
344 KB |
ok |
35 |
Correct |
1 ms |
348 KB |
ok |
36 |
Partially correct |
1 ms |
348 KB |
partial |
37 |
Partially correct |
0 ms |
348 KB |
partial |
38 |
Partially correct |
1 ms |
344 KB |
partial |
39 |
Partially correct |
1 ms |
348 KB |
partial |
40 |
Partially correct |
5 ms |
348 KB |
partial |
41 |
Partially correct |
11 ms |
344 KB |
partial |
42 |
Execution timed out |
4563 ms |
7636 KB |
Time limit exceeded |
43 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
0 ms |
348 KB |
partial |
2 |
Correct |
0 ms |
348 KB |
ok |
3 |
Correct |
0 ms |
348 KB |
ok |
4 |
Correct |
1 ms |
348 KB |
ok |
5 |
Correct |
0 ms |
348 KB |
ok |
6 |
Correct |
0 ms |
348 KB |
ok |
7 |
Correct |
0 ms |
348 KB |
ok |
8 |
Correct |
1 ms |
348 KB |
ok |
9 |
Correct |
10 ms |
3232 KB |
ok |
10 |
Correct |
165 ms |
47444 KB |
ok |
11 |
Correct |
0 ms |
348 KB |
ok |
12 |
Correct |
1 ms |
348 KB |
ok |
13 |
Correct |
0 ms |
344 KB |
ok |
14 |
Correct |
0 ms |
348 KB |
ok |
15 |
Correct |
0 ms |
348 KB |
ok |
16 |
Correct |
0 ms |
348 KB |
ok |
17 |
Correct |
0 ms |
348 KB |
ok |
18 |
Correct |
0 ms |
348 KB |
ok |
19 |
Correct |
0 ms |
348 KB |
ok |
20 |
Correct |
0 ms |
348 KB |
ok |
21 |
Correct |
0 ms |
348 KB |
ok |
22 |
Partially correct |
0 ms |
344 KB |
partial |
23 |
Partially correct |
0 ms |
348 KB |
partial |
24 |
Partially correct |
0 ms |
348 KB |
partial |
25 |
Partially correct |
0 ms |
348 KB |
partial |
26 |
Partially correct |
1 ms |
348 KB |
partial |
27 |
Correct |
0 ms |
348 KB |
ok |
28 |
Correct |
0 ms |
348 KB |
ok |
29 |
Partially correct |
0 ms |
344 KB |
partial |
30 |
Partially correct |
0 ms |
348 KB |
partial |
31 |
Partially correct |
1 ms |
348 KB |
partial |
32 |
Partially correct |
0 ms |
348 KB |
partial |
33 |
Partially correct |
0 ms |
348 KB |
partial |
34 |
Partially correct |
0 ms |
348 KB |
partial |
35 |
Partially correct |
11 ms |
472 KB |
partial |
36 |
Partially correct |
10 ms |
348 KB |
partial |
37 |
Partially correct |
4 ms |
348 KB |
partial |
38 |
Partially correct |
0 ms |
348 KB |
partial |
39 |
Correct |
1 ms |
344 KB |
ok |
40 |
Correct |
1 ms |
348 KB |
ok |
41 |
Partially correct |
1 ms |
348 KB |
partial |
42 |
Partially correct |
0 ms |
348 KB |
partial |
43 |
Partially correct |
1 ms |
344 KB |
partial |
44 |
Partially correct |
1 ms |
348 KB |
partial |
45 |
Partially correct |
5 ms |
348 KB |
partial |
46 |
Partially correct |
11 ms |
344 KB |
partial |
47 |
Execution timed out |
4563 ms |
7636 KB |
Time limit exceeded |
48 |
Halted |
0 ms |
0 KB |
- |