#include "soccer.h"
#include <bits/stdc++.h>
using namespace std;
int n;
pair<int, int> get(int x) {
return {x / n, x % n};
}
int dr[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
int biggest_stadium(int N_, vector<vector<int>> F) {
n = N_;
vector<vector<int>> ps(n, vector<int> (n));
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
ps[i][j] = F[i][j];
if (i) ps[i][j] += ps[i - 1][j];
if (j) ps[i][j] += ps[i][j - 1];
if (i && j) ps[i][j] -= ps[i - 1][j - 1];
}
}
auto sum = [&](int x, int y, int i, int j) {
if (x > i) swap(x, i);
if (y > j) swap(y, j);
int ret = ps[i][j];
if (y) {
ret -= ps[i][y - 1];
}
if (x) {
ret -= ps[x - 1][j];
}
if (x && y) {
ret += ps[x - 1][y - 1];
}
return ret;
};
function<int(int, int, vector<vector<int>>&)> Dfs = [&](int x, int y, vector<vector<int>>& used) {
if (x < 0 || x >= n || y < 0 || y >= n || !used[x][y]) return 0;
used[x][y] = 0;
int ret = 1;
for (int j = 0; j < 4; ++j) {
int nx = x + dr[j], ny = y + dy[j];
ret += Dfs(nx, ny, used);
}
return ret;
};
int ans = 0;
for (int i = 1; i < (1 << (n * n)); ++i) {
vector<vector<int>> used(n, vector<int> (n));
bool bad = false;
vector<pair<int, int>> vec;
int sx = 0, sy = 0;
for (int j = 0; j < n * n; ++j) {
if (i >> j & 1) {
auto [x, y] = get(j);
sx = x, sy = y;
vec.emplace_back(x, y);
used[x][y] = 1;
if (F[x][y]) {
bad = true;
}
}
}
if (bad) {
continue;
}
bool ok = Dfs(sx, sy, used) == __builtin_popcount(i);
for (int k = 0; k < (int) vec.size(); ++k) {
for (int l = 0; l < (int) vec.size(); ++l) {
if (k == l) continue;
auto [x, y] = vec[k];
auto [xx, yy] = vec[l];
bool cur = sum(x, y, x, yy) == 0 && sum(x, yy, xx, yy) == 0;
cur |= sum(x, y, xx, y) == 0 && sum(xx, y, xx, yy) == 0;
ok &= cur;
}
}
if (ok) {
ans = max(ans, __builtin_popcount(i));
}
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4558 ms |
348 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
ok |
2 |
Correct |
1 ms |
600 KB |
ok |
3 |
Incorrect |
336 ms |
420 KB |
wrong |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
ok |
2 |
Correct |
1 ms |
600 KB |
ok |
3 |
Correct |
1 ms |
348 KB |
ok |
4 |
Correct |
0 ms |
348 KB |
ok |
5 |
Correct |
0 ms |
344 KB |
ok |
6 |
Correct |
0 ms |
348 KB |
ok |
7 |
Correct |
0 ms |
344 KB |
ok |
8 |
Correct |
1 ms |
348 KB |
ok |
9 |
Correct |
0 ms |
348 KB |
ok |
10 |
Correct |
1 ms |
344 KB |
ok |
11 |
Correct |
1 ms |
348 KB |
ok |
12 |
Correct |
0 ms |
348 KB |
ok |
13 |
Correct |
0 ms |
348 KB |
ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4558 ms |
348 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4558 ms |
348 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4558 ms |
348 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4558 ms |
348 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |