#include "soccer.h"
#include <bits/stdc++.h>
using namespace std;
typedef int ll;
typedef __int128 lll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
#define MAX 9223372036854775807LL
#define MIN -9223372036854775807LL
#define INF 987654321
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cout << fixed; cout.precision(10);
#define sp << " "
#define en << "\n"
#define compress(v) sort(v.begin(), v.end()), v.erase(unique(v.begin(), v.end()), v.end())
ll n;
ll a[2010][2010];
ll chk[2010][2010];
ll dx[] = {-1, 1, 0, 0};
ll dy[] = {0, 0, -1, 1};
ll biggest_stadium(ll N, vector<vector<ll> > F)
{
n = N;
for(ll i = 1 ; i <= n ; i++)
{
for(ll j = 1 ; j <= n ; j++)
a[i][j] = F[i - 1][j - 1];
}
ll ans = 0;
ll X, Y;
for(ll i = 1 ; i <= n ; i++)
{
for(ll j = 1 ; j <= n ; j++)
{
if(a[i][j] == 0)
X = i, Y = j;
}
}
queue<pll> q;
q.push({X, Y});
chk[X][Y] = 1;
while(!q.empty())
{
pll qq = q.front();
q.pop();
ans++;
for(ll d = 0 ; d < 4 ; d++)
{
ll nx = qq.fi + dx[d];
ll ny = qq.se + dy[d];
if(nx <= 0 || ny <= 0 || nx > n || ny > n)
continue;
if(chk[nx][ny] || a[nx][ny])
continue;
chk[nx][ny] = 1;
q.push({nx, ny});
}
}
for(ll i = 1 ; i <= n ; i++)
{
ll minn = INF, maxx = -INF;
for(ll j = 1 ; j <= n ; j++)
{
if(a[i][j] == 0)
{
minn = min(minn, j);
maxx = max(maxx, j);
}
}
if(minn == INF)
continue;
for(ll j = minn + 1 ; j < maxx ; j++)
{
if(a[i][j] == 1)
return -1;
}
}
for(ll j = 1 ; j <= n ; j++)
{
ll minn = INF, maxx = -INF;
for(ll i = 1 ; i <= n ; i++)
{
if(a[i][j] == 0)
{
minn = min(minn, i);
maxx = max(maxx, i);
}
}
if(minn == INF)
continue;
for(ll i = minn + 1 ; i < maxx ; i++)
{
if(a[i][j] == 1)
return -1;
}
}
return ans;
}
Compilation message
soccer.cpp: In function 'll biggest_stadium(ll, std::vector<std::vector<int> >)':
soccer.cpp:51:12: warning: 'Y' may be used uninitialized in this function [-Wmaybe-uninitialized]
51 | chk[X][Y] = 1;
| ~~~~~~~~~~^~~
soccer.cpp:51:12: warning: 'X' may be used uninitialized in this function [-Wmaybe-uninitialized]
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
1 ms |
2392 KB |
partial |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
ok |
2 |
Correct |
1 ms |
2392 KB |
ok |
3 |
Correct |
1 ms |
2396 KB |
ok |
4 |
Correct |
1 ms |
2392 KB |
ok |
5 |
Correct |
0 ms |
2392 KB |
ok |
6 |
Partially correct |
1 ms |
2392 KB |
partial |
7 |
Partially correct |
2 ms |
6748 KB |
partial |
8 |
Partially correct |
21 ms |
12112 KB |
partial |
9 |
Partially correct |
322 ms |
63316 KB |
partial |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
ok |
2 |
Correct |
1 ms |
2392 KB |
ok |
3 |
Partially correct |
1 ms |
2392 KB |
partial |
4 |
Partially correct |
1 ms |
2392 KB |
partial |
5 |
Incorrect |
1 ms |
2392 KB |
wrong |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
1 ms |
2392 KB |
partial |
2 |
Correct |
1 ms |
2392 KB |
ok |
3 |
Correct |
1 ms |
2392 KB |
ok |
4 |
Partially correct |
1 ms |
2392 KB |
partial |
5 |
Partially correct |
1 ms |
2392 KB |
partial |
6 |
Incorrect |
1 ms |
2392 KB |
wrong |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
1 ms |
2392 KB |
partial |
2 |
Correct |
1 ms |
2392 KB |
ok |
3 |
Correct |
1 ms |
2392 KB |
ok |
4 |
Correct |
1 ms |
2396 KB |
ok |
5 |
Correct |
1 ms |
2392 KB |
ok |
6 |
Partially correct |
1 ms |
2392 KB |
partial |
7 |
Partially correct |
1 ms |
2392 KB |
partial |
8 |
Incorrect |
1 ms |
2392 KB |
wrong |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
1 ms |
2392 KB |
partial |
2 |
Correct |
1 ms |
2392 KB |
ok |
3 |
Correct |
1 ms |
2392 KB |
ok |
4 |
Correct |
1 ms |
2396 KB |
ok |
5 |
Correct |
1 ms |
2392 KB |
ok |
6 |
Partially correct |
1 ms |
2392 KB |
partial |
7 |
Partially correct |
1 ms |
2392 KB |
partial |
8 |
Incorrect |
1 ms |
2392 KB |
wrong |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
1 ms |
2392 KB |
partial |
2 |
Correct |
1 ms |
2392 KB |
ok |
3 |
Correct |
1 ms |
2392 KB |
ok |
4 |
Correct |
1 ms |
2396 KB |
ok |
5 |
Correct |
1 ms |
2392 KB |
ok |
6 |
Correct |
0 ms |
2392 KB |
ok |
7 |
Partially correct |
1 ms |
2392 KB |
partial |
8 |
Partially correct |
2 ms |
6748 KB |
partial |
9 |
Partially correct |
21 ms |
12112 KB |
partial |
10 |
Partially correct |
322 ms |
63316 KB |
partial |
11 |
Partially correct |
1 ms |
2392 KB |
partial |
12 |
Partially correct |
1 ms |
2392 KB |
partial |
13 |
Incorrect |
1 ms |
2392 KB |
wrong |
14 |
Halted |
0 ms |
0 KB |
- |