#include "soccer.h"
#include <bits/stdc++.h>
using namespace std;
int biggest_stadium(int N, vector<vector<int>> F)
{
bool good = true;
for (int i = 0; i < N && good; i++)
{
bool seen0 = false;
bool seen1 = false;
for(int j = 0; j < N; j++)
{
if (seen1 && !F[i][j])
{
good = false;
break;
}
if (seen0 && F[i][j])
{
seen1 = true;
}
if(!F[i][j])
{
seen0 = true;
}
}
}
for(int j = 0; j < N && good; j++)
{
bool seen0 = false;
bool seen1 = false;
for(int i = 0; i < N; i++)
{
if (seen1 && !F[i][j])
{
good = false;
break;
}
if (seen0 && F[i][j])
{
seen1 = true;
}
if(!F[i][j])
{
seen0 = true;
}
}
}
vector<vector<bool>> visited(N, vector<bool>(N, false));
queue<pair<int, int>> q;
int vis = 0;
for(int i = 0; i < N && q.empty(); i++)
{
for(int j = 0; j < N && q.empty(); j++)
{
if(!F[i][j])
{
q.push({i, j});
visited[i][j] = true;
vis = 1;
}
}
}
vector<int> dx = {0, 0, 1, -1};
vector<int> dy = {1, -1, 0, 0};
while(!q.empty())
{
auto [i, j] = q.front();
q.pop();
for (int k = 0; k < 4; k++)
{
int ni = i + dx[k];
int nj = j + dy[k];
if (ni < 0 || ni >= N || nj < 0 || nj >= N || visited[ni][nj] || F[ni][nj])
continue;
visited[ni][nj] = true;
vis++;
q.push({ni, nj});
}
}
int empty = 0;
for(int i = 0; i < N; i++)
{
for(int j = 0; j < N; j++) {
if(!F[i][j])
empty++;
}
}
if (vis != empty)
good = false;
if (good)
return empty;
else
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
partial |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
ok |
2 |
Correct |
0 ms |
212 KB |
ok |
3 |
Correct |
1 ms |
212 KB |
ok |
4 |
Correct |
1 ms |
212 KB |
ok |
5 |
Correct |
0 ms |
212 KB |
ok |
6 |
Partially correct |
0 ms |
212 KB |
partial |
7 |
Partially correct |
1 ms |
340 KB |
partial |
8 |
Partially correct |
26 ms |
2388 KB |
partial |
9 |
Partially correct |
298 ms |
32332 KB |
partial |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
ok |
2 |
Correct |
0 ms |
212 KB |
ok |
3 |
Partially correct |
0 ms |
212 KB |
partial |
4 |
Partially correct |
0 ms |
212 KB |
partial |
5 |
Incorrect |
0 ms |
212 KB |
wrong |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
partial |
2 |
Correct |
0 ms |
212 KB |
ok |
3 |
Correct |
0 ms |
212 KB |
ok |
4 |
Partially correct |
0 ms |
212 KB |
partial |
5 |
Partially correct |
0 ms |
212 KB |
partial |
6 |
Incorrect |
0 ms |
212 KB |
wrong |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
partial |
2 |
Correct |
0 ms |
212 KB |
ok |
3 |
Correct |
0 ms |
212 KB |
ok |
4 |
Correct |
1 ms |
212 KB |
ok |
5 |
Correct |
1 ms |
212 KB |
ok |
6 |
Partially correct |
0 ms |
212 KB |
partial |
7 |
Partially correct |
0 ms |
212 KB |
partial |
8 |
Incorrect |
0 ms |
212 KB |
wrong |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
partial |
2 |
Correct |
0 ms |
212 KB |
ok |
3 |
Correct |
0 ms |
212 KB |
ok |
4 |
Correct |
1 ms |
212 KB |
ok |
5 |
Correct |
1 ms |
212 KB |
ok |
6 |
Partially correct |
0 ms |
212 KB |
partial |
7 |
Partially correct |
0 ms |
212 KB |
partial |
8 |
Incorrect |
0 ms |
212 KB |
wrong |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
partial |
2 |
Correct |
0 ms |
212 KB |
ok |
3 |
Correct |
0 ms |
212 KB |
ok |
4 |
Correct |
1 ms |
212 KB |
ok |
5 |
Correct |
1 ms |
212 KB |
ok |
6 |
Correct |
0 ms |
212 KB |
ok |
7 |
Partially correct |
0 ms |
212 KB |
partial |
8 |
Partially correct |
1 ms |
340 KB |
partial |
9 |
Partially correct |
26 ms |
2388 KB |
partial |
10 |
Partially correct |
298 ms |
32332 KB |
partial |
11 |
Partially correct |
0 ms |
212 KB |
partial |
12 |
Partially correct |
0 ms |
212 KB |
partial |
13 |
Incorrect |
0 ms |
212 KB |
wrong |
14 |
Halted |
0 ms |
0 KB |
- |