#include "soccer.h"
#include <bits/stdc++.h>
using namespace std;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
bool check(pair<int,int> u, pair<int,int> v, vector<vector<int>> &F) {
if (u.first == v.first) {
for (int i=min(u.second, v.second); i<=max(u.second, v.second); i++) {
if (F[u.first][i] == 1) return 0;
}
}
else if (u.second == v.second) {
for (int i=min(u.first, v.first); i<=max(u.first, v.first); i++) {
if (F[i][u.second] == 1) return 0;
}
}
else assert(0);
return 1;
}
int biggest_stadium(int N, vector<vector<int>> F) {
vector<vector<int>> vis(N, vector<int>(N, 0));
queue<pair<int,int>> q;
for (int i=0; i<N; i++) {
for (int j=0; j<N; j++) {
if (F[i][j] == 0) {
vis[i][j] = 1;
q.push({i, j});
break;
}
}
if (!q.empty()) break;
}
while (!q.empty()) {
int x = q.front().first;
int y = q.front().second;
q.pop();
for (int k=0; k<4; k++) {
int nx = x + dx[k];
int ny = y + dy[k];
if (nx < 0 || nx >= N || ny < 0 || ny >= N) continue;
if (vis[nx][ny]) continue;
vis[nx][ny] = 1;
q.push({nx, ny});
}
}
vector<pair<int,int>> blank;
for (int i=0; i<N; i++) {
for (int j=0; j<N; j++) {
if (F[i][j] == 0 && vis[i][j] == 0) {
return 0;
}
if (F[i][j] == 0) {
blank.push_back({i, j});
}
}
}
for (auto &u : blank) {
for (auto &v : blank) {
if (u == v) continue;
if (u.first == v.first || u.second == v.second) {
if (!check(u, v, F)) return 0;
}
else {
bool f1 = check(u, {u.first, v.second}, F) && check({u.first, v.second}, v, F);
bool f2 = check(u, {v.first, u.second}, F) && check({v.first, u.second}, v, F);
if (!f1 && !f2) return 0;
}
}
}
return blank.size();
/*int tot = 0;
bool flag = false;
int pl = -1, pr = -1;
vector<pair<int,int>> ran;
for (int i=0; i<N; i++) {
int l = -1, r = -1, cnt = 0;
for (int j=0; j<N; j++) {
if (F[i][j] == 0) {
if (l == -1) l = j;
r = j;
cnt ++;
}
}
if (cnt == 0) {
pl = -1; pr = -1;
continue;
}
ran.push_back({l, r});
if (r - l + 1 != cnt) {
return 0;
}
if (pl != -1) {
if (!flag) {
if (l <= pl && pr <= r) {}
else if (pl <= l && r <= pr) {
flag = true;
}
else return 0;
}
else {
if (pl <= l && r <= pr) {}
else return 0;
}
}
pl = l; pr = r;
tot += cnt;
}
sort(ran.begin(), ran.end(), [&](pair<int,int> &u, pair<int,int> &v) {
return u.second - u.first < v.second - v.first;
});
for (int i=0; i+1<ran.size(); i++) {
if (ran[i+1].first <= ran[i].first && ran[i].second <= ran[i+1].second) {}
else return 0;
}
return tot;*/
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
0 ms |
348 KB |
partial |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
ok |
2 |
Correct |
1 ms |
348 KB |
ok |
3 |
Correct |
1 ms |
348 KB |
ok |
4 |
Correct |
1 ms |
348 KB |
ok |
5 |
Correct |
0 ms |
348 KB |
ok |
6 |
Partially correct |
1 ms |
348 KB |
partial |
7 |
Partially correct |
99 ms |
604 KB |
partial |
8 |
Execution timed out |
4547 ms |
6100 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
ok |
2 |
Correct |
1 ms |
348 KB |
ok |
3 |
Partially correct |
0 ms |
348 KB |
partial |
4 |
Partially correct |
0 ms |
348 KB |
partial |
5 |
Partially correct |
0 ms |
348 KB |
partial |
6 |
Partially correct |
0 ms |
344 KB |
partial |
7 |
Partially correct |
0 ms |
348 KB |
partial |
8 |
Correct |
0 ms |
348 KB |
ok |
9 |
Correct |
0 ms |
348 KB |
ok |
10 |
Partially correct |
0 ms |
348 KB |
partial |
11 |
Partially correct |
0 ms |
348 KB |
partial |
12 |
Partially correct |
0 ms |
348 KB |
partial |
13 |
Correct |
0 ms |
348 KB |
ok |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
0 ms |
348 KB |
partial |
2 |
Correct |
1 ms |
344 KB |
ok |
3 |
Correct |
1 ms |
348 KB |
ok |
4 |
Partially correct |
0 ms |
348 KB |
partial |
5 |
Partially correct |
0 ms |
348 KB |
partial |
6 |
Partially correct |
0 ms |
348 KB |
partial |
7 |
Partially correct |
0 ms |
344 KB |
partial |
8 |
Partially correct |
0 ms |
348 KB |
partial |
9 |
Correct |
0 ms |
348 KB |
ok |
10 |
Correct |
0 ms |
348 KB |
ok |
11 |
Partially correct |
0 ms |
348 KB |
partial |
12 |
Partially correct |
0 ms |
348 KB |
partial |
13 |
Partially correct |
0 ms |
348 KB |
partial |
14 |
Correct |
0 ms |
348 KB |
ok |
15 |
Partially correct |
0 ms |
348 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 |
1 ms |
348 KB |
ok |
22 |
Partially correct |
0 ms |
348 KB |
partial |
23 |
Partially correct |
0 ms |
348 KB |
partial |
24 |
Partially correct |
1 ms |
348 KB |
partial |
25 |
Partially correct |
1 ms |
348 KB |
partial |
26 |
Partially correct |
1 ms |
348 KB |
partial |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
0 ms |
348 KB |
partial |
2 |
Correct |
1 ms |
344 KB |
ok |
3 |
Correct |
1 ms |
348 KB |
ok |
4 |
Correct |
1 ms |
348 KB |
ok |
5 |
Correct |
1 ms |
348 KB |
ok |
6 |
Partially correct |
0 ms |
348 KB |
partial |
7 |
Partially correct |
0 ms |
348 KB |
partial |
8 |
Partially correct |
0 ms |
348 KB |
partial |
9 |
Partially correct |
0 ms |
344 KB |
partial |
10 |
Partially correct |
0 ms |
348 KB |
partial |
11 |
Correct |
0 ms |
348 KB |
ok |
12 |
Correct |
0 ms |
348 KB |
ok |
13 |
Partially correct |
0 ms |
348 KB |
partial |
14 |
Partially correct |
0 ms |
348 KB |
partial |
15 |
Partially correct |
0 ms |
348 KB |
partial |
16 |
Correct |
0 ms |
348 KB |
ok |
17 |
Partially correct |
0 ms |
348 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 |
1 ms |
348 KB |
ok |
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 |
Partially correct |
1 ms |
348 KB |
partial |
28 |
Partially correct |
1 ms |
348 KB |
partial |
29 |
Partially correct |
1 ms |
348 KB |
partial |
30 |
Partially correct |
0 ms |
348 KB |
partial |
31 |
Partially correct |
0 ms |
348 KB |
partial |
32 |
Partially correct |
0 ms |
348 KB |
partial |
33 |
Partially correct |
1 ms |
348 KB |
partial |
34 |
Correct |
1 ms |
348 KB |
ok |
35 |
Correct |
2 ms |
348 KB |
ok |
36 |
Partially correct |
1 ms |
348 KB |
partial |
37 |
Partially correct |
1 ms |
348 KB |
partial |
38 |
Partially correct |
0 ms |
344 KB |
partial |
39 |
Partially correct |
1 ms |
344 KB |
partial |
40 |
Partially correct |
1 ms |
600 KB |
partial |
41 |
Partially correct |
0 ms |
348 KB |
partial |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
0 ms |
348 KB |
partial |
2 |
Correct |
1 ms |
344 KB |
ok |
3 |
Correct |
1 ms |
348 KB |
ok |
4 |
Correct |
1 ms |
348 KB |
ok |
5 |
Correct |
1 ms |
348 KB |
ok |
6 |
Partially correct |
0 ms |
348 KB |
partial |
7 |
Partially correct |
0 ms |
348 KB |
partial |
8 |
Partially correct |
0 ms |
348 KB |
partial |
9 |
Partially correct |
0 ms |
344 KB |
partial |
10 |
Partially correct |
0 ms |
348 KB |
partial |
11 |
Correct |
0 ms |
348 KB |
ok |
12 |
Correct |
0 ms |
348 KB |
ok |
13 |
Partially correct |
0 ms |
348 KB |
partial |
14 |
Partially correct |
0 ms |
348 KB |
partial |
15 |
Partially correct |
0 ms |
348 KB |
partial |
16 |
Correct |
0 ms |
348 KB |
ok |
17 |
Partially correct |
0 ms |
348 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 |
1 ms |
348 KB |
ok |
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 |
Partially correct |
1 ms |
348 KB |
partial |
28 |
Partially correct |
1 ms |
348 KB |
partial |
29 |
Partially correct |
1 ms |
348 KB |
partial |
30 |
Partially correct |
0 ms |
348 KB |
partial |
31 |
Partially correct |
0 ms |
348 KB |
partial |
32 |
Partially correct |
0 ms |
348 KB |
partial |
33 |
Partially correct |
1 ms |
348 KB |
partial |
34 |
Correct |
1 ms |
348 KB |
ok |
35 |
Correct |
2 ms |
348 KB |
ok |
36 |
Partially correct |
1 ms |
348 KB |
partial |
37 |
Partially correct |
1 ms |
348 KB |
partial |
38 |
Partially correct |
0 ms |
344 KB |
partial |
39 |
Partially correct |
1 ms |
344 KB |
partial |
40 |
Partially correct |
1 ms |
600 KB |
partial |
41 |
Partially correct |
0 ms |
348 KB |
partial |
42 |
Partially correct |
20 ms |
6104 KB |
partial |
43 |
Partially correct |
36 ms |
6092 KB |
partial |
44 |
Partially correct |
21 ms |
6012 KB |
partial |
45 |
Partially correct |
22 ms |
6104 KB |
partial |
46 |
Partially correct |
20 ms |
6092 KB |
partial |
47 |
Partially correct |
27 ms |
6100 KB |
partial |
48 |
Execution timed out |
4598 ms |
4868 KB |
Time limit exceeded |
49 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
0 ms |
348 KB |
partial |
2 |
Correct |
1 ms |
344 KB |
ok |
3 |
Correct |
1 ms |
348 KB |
ok |
4 |
Correct |
1 ms |
348 KB |
ok |
5 |
Correct |
1 ms |
348 KB |
ok |
6 |
Correct |
0 ms |
348 KB |
ok |
7 |
Partially correct |
1 ms |
348 KB |
partial |
8 |
Partially correct |
99 ms |
604 KB |
partial |
9 |
Execution timed out |
4547 ms |
6100 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |