#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});
}
}
vector<pll> vv;
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;
vv.push_back({minn, maxx});
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;
}
}
for(auto &i : vv)
{
for(auto &j : vv)
{
if(i.fi <= j.fi && j.se <= i.se)
continue;
if(j.fi <= i.fi && i.se <= j.se)
continue;
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 |
2396 KB |
partial |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
ok |
2 |
Correct |
1 ms |
2396 KB |
ok |
3 |
Correct |
1 ms |
2396 KB |
ok |
4 |
Correct |
1 ms |
2396 KB |
ok |
5 |
Correct |
0 ms |
2396 KB |
ok |
6 |
Partially correct |
1 ms |
2552 KB |
partial |
7 |
Partially correct |
2 ms |
6748 KB |
partial |
8 |
Partially correct |
21 ms |
12124 KB |
partial |
9 |
Partially correct |
324 ms |
63264 KB |
partial |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
ok |
2 |
Correct |
1 ms |
2396 KB |
ok |
3 |
Partially correct |
1 ms |
2392 KB |
partial |
4 |
Partially correct |
1 ms |
2396 KB |
partial |
5 |
Partially correct |
1 ms |
2396 KB |
partial |
6 |
Partially correct |
1 ms |
2396 KB |
partial |
7 |
Partially correct |
0 ms |
2396 KB |
partial |
8 |
Correct |
0 ms |
2396 KB |
ok |
9 |
Correct |
0 ms |
2396 KB |
ok |
10 |
Partially correct |
1 ms |
2396 KB |
partial |
11 |
Partially correct |
1 ms |
2392 KB |
partial |
12 |
Partially correct |
1 ms |
2392 KB |
partial |
13 |
Correct |
1 ms |
2396 KB |
ok |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
1 ms |
2396 KB |
partial |
2 |
Correct |
1 ms |
2396 KB |
ok |
3 |
Correct |
1 ms |
2396 KB |
ok |
4 |
Partially correct |
1 ms |
2392 KB |
partial |
5 |
Partially correct |
1 ms |
2396 KB |
partial |
6 |
Partially correct |
1 ms |
2396 KB |
partial |
7 |
Partially correct |
1 ms |
2396 KB |
partial |
8 |
Partially correct |
0 ms |
2396 KB |
partial |
9 |
Correct |
0 ms |
2396 KB |
ok |
10 |
Correct |
0 ms |
2396 KB |
ok |
11 |
Partially correct |
1 ms |
2396 KB |
partial |
12 |
Partially correct |
1 ms |
2392 KB |
partial |
13 |
Partially correct |
1 ms |
2392 KB |
partial |
14 |
Correct |
1 ms |
2396 KB |
ok |
15 |
Partially correct |
1 ms |
2396 KB |
partial |
16 |
Partially correct |
1 ms |
2396 KB |
partial |
17 |
Partially correct |
1 ms |
2396 KB |
partial |
18 |
Partially correct |
0 ms |
2396 KB |
partial |
19 |
Partially correct |
1 ms |
2396 KB |
partial |
20 |
Correct |
1 ms |
2396 KB |
ok |
21 |
Correct |
0 ms |
2396 KB |
ok |
22 |
Partially correct |
1 ms |
2392 KB |
partial |
23 |
Partially correct |
1 ms |
2392 KB |
partial |
24 |
Partially correct |
1 ms |
2396 KB |
partial |
25 |
Partially correct |
1 ms |
2396 KB |
partial |
26 |
Partially correct |
0 ms |
2396 KB |
partial |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
1 ms |
2396 KB |
partial |
2 |
Correct |
1 ms |
2396 KB |
ok |
3 |
Correct |
1 ms |
2396 KB |
ok |
4 |
Correct |
1 ms |
2396 KB |
ok |
5 |
Correct |
1 ms |
2396 KB |
ok |
6 |
Partially correct |
1 ms |
2392 KB |
partial |
7 |
Partially correct |
1 ms |
2396 KB |
partial |
8 |
Partially correct |
1 ms |
2396 KB |
partial |
9 |
Partially correct |
1 ms |
2396 KB |
partial |
10 |
Partially correct |
0 ms |
2396 KB |
partial |
11 |
Correct |
0 ms |
2396 KB |
ok |
12 |
Correct |
0 ms |
2396 KB |
ok |
13 |
Partially correct |
1 ms |
2396 KB |
partial |
14 |
Partially correct |
1 ms |
2392 KB |
partial |
15 |
Partially correct |
1 ms |
2392 KB |
partial |
16 |
Correct |
1 ms |
2396 KB |
ok |
17 |
Partially correct |
1 ms |
2396 KB |
partial |
18 |
Partially correct |
1 ms |
2396 KB |
partial |
19 |
Partially correct |
1 ms |
2396 KB |
partial |
20 |
Partially correct |
0 ms |
2396 KB |
partial |
21 |
Partially correct |
1 ms |
2396 KB |
partial |
22 |
Correct |
1 ms |
2396 KB |
ok |
23 |
Correct |
0 ms |
2396 KB |
ok |
24 |
Partially correct |
1 ms |
2392 KB |
partial |
25 |
Partially correct |
1 ms |
2392 KB |
partial |
26 |
Partially correct |
1 ms |
2396 KB |
partial |
27 |
Partially correct |
1 ms |
2396 KB |
partial |
28 |
Partially correct |
0 ms |
2396 KB |
partial |
29 |
Partially correct |
1 ms |
2396 KB |
partial |
30 |
Partially correct |
1 ms |
4444 KB |
partial |
31 |
Partially correct |
1 ms |
4504 KB |
partial |
32 |
Partially correct |
1 ms |
4444 KB |
partial |
33 |
Partially correct |
1 ms |
4444 KB |
partial |
34 |
Correct |
1 ms |
4440 KB |
ok |
35 |
Correct |
1 ms |
4440 KB |
ok |
36 |
Partially correct |
1 ms |
2548 KB |
partial |
37 |
Partially correct |
1 ms |
4696 KB |
partial |
38 |
Partially correct |
1 ms |
4444 KB |
partial |
39 |
Partially correct |
2 ms |
4444 KB |
partial |
40 |
Partially correct |
1 ms |
2396 KB |
partial |
41 |
Partially correct |
1 ms |
4444 KB |
partial |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
1 ms |
2396 KB |
partial |
2 |
Correct |
1 ms |
2396 KB |
ok |
3 |
Correct |
1 ms |
2396 KB |
ok |
4 |
Correct |
1 ms |
2396 KB |
ok |
5 |
Correct |
1 ms |
2396 KB |
ok |
6 |
Partially correct |
1 ms |
2392 KB |
partial |
7 |
Partially correct |
1 ms |
2396 KB |
partial |
8 |
Partially correct |
1 ms |
2396 KB |
partial |
9 |
Partially correct |
1 ms |
2396 KB |
partial |
10 |
Partially correct |
0 ms |
2396 KB |
partial |
11 |
Correct |
0 ms |
2396 KB |
ok |
12 |
Correct |
0 ms |
2396 KB |
ok |
13 |
Partially correct |
1 ms |
2396 KB |
partial |
14 |
Partially correct |
1 ms |
2392 KB |
partial |
15 |
Partially correct |
1 ms |
2392 KB |
partial |
16 |
Correct |
1 ms |
2396 KB |
ok |
17 |
Partially correct |
1 ms |
2396 KB |
partial |
18 |
Partially correct |
1 ms |
2396 KB |
partial |
19 |
Partially correct |
1 ms |
2396 KB |
partial |
20 |
Partially correct |
0 ms |
2396 KB |
partial |
21 |
Partially correct |
1 ms |
2396 KB |
partial |
22 |
Correct |
1 ms |
2396 KB |
ok |
23 |
Correct |
0 ms |
2396 KB |
ok |
24 |
Partially correct |
1 ms |
2392 KB |
partial |
25 |
Partially correct |
1 ms |
2392 KB |
partial |
26 |
Partially correct |
1 ms |
2396 KB |
partial |
27 |
Partially correct |
1 ms |
2396 KB |
partial |
28 |
Partially correct |
0 ms |
2396 KB |
partial |
29 |
Partially correct |
1 ms |
2396 KB |
partial |
30 |
Partially correct |
1 ms |
4444 KB |
partial |
31 |
Partially correct |
1 ms |
4504 KB |
partial |
32 |
Partially correct |
1 ms |
4444 KB |
partial |
33 |
Partially correct |
1 ms |
4444 KB |
partial |
34 |
Correct |
1 ms |
4440 KB |
ok |
35 |
Correct |
1 ms |
4440 KB |
ok |
36 |
Partially correct |
1 ms |
2548 KB |
partial |
37 |
Partially correct |
1 ms |
4696 KB |
partial |
38 |
Partially correct |
1 ms |
4444 KB |
partial |
39 |
Partially correct |
2 ms |
4444 KB |
partial |
40 |
Partially correct |
1 ms |
2396 KB |
partial |
41 |
Partially correct |
1 ms |
4444 KB |
partial |
42 |
Partially correct |
22 ms |
12124 KB |
partial |
43 |
Partially correct |
23 ms |
12112 KB |
partial |
44 |
Partially correct |
26 ms |
12112 KB |
partial |
45 |
Partially correct |
21 ms |
12112 KB |
partial |
46 |
Partially correct |
22 ms |
12112 KB |
partial |
47 |
Partially correct |
21 ms |
12124 KB |
partial |
48 |
Correct |
20 ms |
11868 KB |
ok |
49 |
Partially correct |
19 ms |
11868 KB |
partial |
50 |
Partially correct |
20 ms |
12124 KB |
partial |
51 |
Partially correct |
17 ms |
10588 KB |
partial |
52 |
Partially correct |
17 ms |
10844 KB |
partial |
53 |
Partially correct |
18 ms |
10588 KB |
partial |
54 |
Partially correct |
18 ms |
11612 KB |
partial |
55 |
Partially correct |
18 ms |
11864 KB |
partial |
56 |
Partially correct |
19 ms |
10656 KB |
partial |
57 |
Partially correct |
20 ms |
12112 KB |
partial |
58 |
Partially correct |
20 ms |
12120 KB |
partial |
59 |
Partially correct |
20 ms |
12116 KB |
partial |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
1 ms |
2396 KB |
partial |
2 |
Correct |
1 ms |
2396 KB |
ok |
3 |
Correct |
1 ms |
2396 KB |
ok |
4 |
Correct |
1 ms |
2396 KB |
ok |
5 |
Correct |
1 ms |
2396 KB |
ok |
6 |
Correct |
0 ms |
2396 KB |
ok |
7 |
Partially correct |
1 ms |
2552 KB |
partial |
8 |
Partially correct |
2 ms |
6748 KB |
partial |
9 |
Partially correct |
21 ms |
12124 KB |
partial |
10 |
Partially correct |
324 ms |
63264 KB |
partial |
11 |
Partially correct |
1 ms |
2392 KB |
partial |
12 |
Partially correct |
1 ms |
2396 KB |
partial |
13 |
Partially correct |
1 ms |
2396 KB |
partial |
14 |
Partially correct |
1 ms |
2396 KB |
partial |
15 |
Partially correct |
0 ms |
2396 KB |
partial |
16 |
Correct |
0 ms |
2396 KB |
ok |
17 |
Correct |
0 ms |
2396 KB |
ok |
18 |
Partially correct |
1 ms |
2396 KB |
partial |
19 |
Partially correct |
1 ms |
2392 KB |
partial |
20 |
Partially correct |
1 ms |
2392 KB |
partial |
21 |
Correct |
1 ms |
2396 KB |
ok |
22 |
Partially correct |
1 ms |
2396 KB |
partial |
23 |
Partially correct |
1 ms |
2396 KB |
partial |
24 |
Partially correct |
1 ms |
2396 KB |
partial |
25 |
Partially correct |
0 ms |
2396 KB |
partial |
26 |
Partially correct |
1 ms |
2396 KB |
partial |
27 |
Correct |
1 ms |
2396 KB |
ok |
28 |
Correct |
0 ms |
2396 KB |
ok |
29 |
Partially correct |
1 ms |
2392 KB |
partial |
30 |
Partially correct |
1 ms |
2392 KB |
partial |
31 |
Partially correct |
1 ms |
2396 KB |
partial |
32 |
Partially correct |
1 ms |
2396 KB |
partial |
33 |
Partially correct |
0 ms |
2396 KB |
partial |
34 |
Partially correct |
1 ms |
2396 KB |
partial |
35 |
Partially correct |
1 ms |
4444 KB |
partial |
36 |
Partially correct |
1 ms |
4504 KB |
partial |
37 |
Partially correct |
1 ms |
4444 KB |
partial |
38 |
Partially correct |
1 ms |
4444 KB |
partial |
39 |
Correct |
1 ms |
4440 KB |
ok |
40 |
Correct |
1 ms |
4440 KB |
ok |
41 |
Partially correct |
1 ms |
2548 KB |
partial |
42 |
Partially correct |
1 ms |
4696 KB |
partial |
43 |
Partially correct |
1 ms |
4444 KB |
partial |
44 |
Partially correct |
2 ms |
4444 KB |
partial |
45 |
Partially correct |
1 ms |
2396 KB |
partial |
46 |
Partially correct |
1 ms |
4444 KB |
partial |
47 |
Partially correct |
22 ms |
12124 KB |
partial |
48 |
Partially correct |
23 ms |
12112 KB |
partial |
49 |
Partially correct |
26 ms |
12112 KB |
partial |
50 |
Partially correct |
21 ms |
12112 KB |
partial |
51 |
Partially correct |
22 ms |
12112 KB |
partial |
52 |
Partially correct |
21 ms |
12124 KB |
partial |
53 |
Correct |
20 ms |
11868 KB |
ok |
54 |
Partially correct |
19 ms |
11868 KB |
partial |
55 |
Partially correct |
20 ms |
12124 KB |
partial |
56 |
Partially correct |
17 ms |
10588 KB |
partial |
57 |
Partially correct |
17 ms |
10844 KB |
partial |
58 |
Partially correct |
18 ms |
10588 KB |
partial |
59 |
Partially correct |
18 ms |
11612 KB |
partial |
60 |
Partially correct |
18 ms |
11864 KB |
partial |
61 |
Partially correct |
19 ms |
10656 KB |
partial |
62 |
Partially correct |
20 ms |
12112 KB |
partial |
63 |
Partially correct |
20 ms |
12120 KB |
partial |
64 |
Partially correct |
20 ms |
12116 KB |
partial |
65 |
Partially correct |
336 ms |
63552 KB |
partial |
66 |
Partially correct |
253 ms |
48720 KB |
partial |
67 |
Partially correct |
256 ms |
48720 KB |
partial |
68 |
Partially correct |
335 ms |
63252 KB |
partial |
69 |
Partially correct |
325 ms |
63300 KB |
partial |
70 |
Partially correct |
322 ms |
63264 KB |
partial |
71 |
Partially correct |
317 ms |
63260 KB |
partial |
72 |
Partially correct |
319 ms |
63312 KB |
partial |
73 |
Correct |
302 ms |
61900 KB |
ok |
74 |
Correct |
319 ms |
61992 KB |
ok |
75 |
Partially correct |
296 ms |
61988 KB |
partial |
76 |
Partially correct |
308 ms |
63316 KB |
partial |
77 |
Partially correct |
330 ms |
63300 KB |
partial |
78 |
Partially correct |
241 ms |
48724 KB |
partial |
79 |
Partially correct |
252 ms |
48676 KB |
partial |
80 |
Partially correct |
242 ms |
48672 KB |
partial |
81 |
Partially correct |
255 ms |
48672 KB |
partial |
82 |
Partially correct |
250 ms |
48832 KB |
partial |
83 |
Partially correct |
252 ms |
48720 KB |
partial |
84 |
Partially correct |
268 ms |
51996 KB |
partial |
85 |
Partially correct |
263 ms |
50260 KB |
partial |
86 |
Partially correct |
277 ms |
53276 KB |
partial |
87 |
Partially correct |
278 ms |
56096 KB |
partial |
88 |
Partially correct |
290 ms |
57232 KB |
partial |
89 |
Partially correct |
319 ms |
63256 KB |
partial |
90 |
Partially correct |
309 ms |
63468 KB |
partial |
91 |
Partially correct |
308 ms |
62804 KB |
partial |
92 |
Partially correct |
260 ms |
48672 KB |
partial |
93 |
Partially correct |
249 ms |
48720 KB |
partial |
94 |
Partially correct |
246 ms |
48668 KB |
partial |
95 |
Partially correct |
246 ms |
48672 KB |
partial |
96 |
Partially correct |
245 ms |
48720 KB |
partial |
97 |
Partially correct |
266 ms |
48724 KB |
partial |
98 |
Partially correct |
251 ms |
48724 KB |
partial |
99 |
Partially correct |
257 ms |
56864 KB |
partial |
100 |
Partially correct |
297 ms |
63292 KB |
partial |
101 |
Partially correct |
269 ms |
53280 KB |
partial |
102 |
Partially correct |
255 ms |
53588 KB |
partial |
103 |
Partially correct |
313 ms |
63364 KB |
partial |
104 |
Partially correct |
273 ms |
55632 KB |
partial |
105 |
Partially correct |
252 ms |
55076 KB |
partial |
106 |
Partially correct |
287 ms |
63232 KB |
partial |
107 |
Partially correct |
290 ms |
63008 KB |
partial |
108 |
Partially correct |
252 ms |
48672 KB |
partial |
109 |
Partially correct |
252 ms |
48760 KB |
partial |