#include <bits/stdc++.h>
#include "soccer.h"
using namespace std;
const int nmax = 2e3;
int n;
int a[nmax + 5][nmax + 5];
int st[nmax + 5], dr[nmax + 5];
int Minst[nmax + 5], Maxdr[nmax + 5];
bool verif()
{
for(int i=0; i<=n; i++)
{
st[i] = n + 1;
dr[i] = 0;
}
for(int i=1; i<=n; i++)
{
for(int j=1; j<=n; j++)
{
if(a[i][j]==0 && a[i][j - 1]==1)
{
if(st[i]!=n+1)
{
return false;
}
st[i] = j;
}
if(a[i][j]==0)
{
dr[i] = j;
}
}
}
Minst[0] = n + 1;
for(int i=1;i<=n;i++)
{
Minst[i] = min(Minst[i - 1], st[i]);
Maxdr[i] = max(Maxdr[i - 1], dr[i]);
}
bool desc = false, start = false;
stack<int> stl, str;
for(int i=1; i<=n; i++)
{
if(st[i]!=n+1 && st[i - 1]==n+1 && start)
{
return false;
}
if(st[i]!=n+1)
{
start = true;
/* if(st[i - 1]!=n+1 && st[i] < st[i - 1] && desc)
{
return false;
}
if(st[i - 1]!=n+1 && st[i] > st[i - 1])
{
desc = true;
}
if(dr[i - 1] && dr[i] > dr[i - 1] && desc)
{
return false;
}
if(dr[i - 1] && dr[i] < dr[i - 1])
{
desc = true;
}
*/
int u_st = 0, u_dr = 0;
while(!stl.empty() && st[i] >= st[stl.top()])
{
stl.pop();
}
if(stl.empty())
{
u_st = 0;
}
else
{
u_st = stl.top();
}
stl.push(i);
while(!str.empty() && dr[i] <= dr[str.top()])
{
str.pop();
}
if(str.empty())
{
u_dr = 0;
}
else
{
u_dr = str.top();
}
str.push(i);
if(Minst[u_dr] < st[i])
{
return false;
}
if(Maxdr[u_st] > dr[i])
{
return false;
}
}
}
return true;
}
int biggest_stadium(int N, std::vector<std::vector<int>> F)
{
n = N;
int nre = 0;
for(int i=1; i<=n; i++)
{
for(int j=1; j<=n; j++)
{
a[i][j] = F[i - 1][j - 1];
nre += (1 - a[i][j]);
}
}
for(int i=0; i<=n; i++)
{
a[i][0] = a[0][i] = a[i][n + 1] = a[n + 1][i] = 1;
}
bool ok = verif();
if(ok)
{
return nre;
}
return 0;
}
Compilation message
soccer.cpp: In function 'bool verif()':
soccer.cpp:47:10: warning: unused variable 'desc' [-Wunused-variable]
47 | bool desc = false, start = false;
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
0 ms |
344 KB |
partial |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
ok |
2 |
Correct |
0 ms |
348 KB |
ok |
3 |
Correct |
1 ms |
348 KB |
ok |
4 |
Correct |
1 ms |
344 KB |
ok |
5 |
Correct |
0 ms |
344 KB |
ok |
6 |
Partially correct |
0 ms |
344 KB |
partial |
7 |
Partially correct |
1 ms |
2648 KB |
partial |
8 |
Partially correct |
16 ms |
6492 KB |
partial |
9 |
Partially correct |
249 ms |
47400 KB |
partial |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
ok |
2 |
Correct |
0 ms |
348 KB |
ok |
3 |
Partially correct |
0 ms |
344 KB |
partial |
4 |
Incorrect |
0 ms |
344 KB |
wrong |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
0 ms |
344 KB |
partial |
2 |
Correct |
0 ms |
344 KB |
ok |
3 |
Correct |
0 ms |
348 KB |
ok |
4 |
Partially correct |
0 ms |
344 KB |
partial |
5 |
Incorrect |
0 ms |
344 KB |
wrong |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
0 ms |
344 KB |
partial |
2 |
Correct |
0 ms |
344 KB |
ok |
3 |
Correct |
0 ms |
348 KB |
ok |
4 |
Correct |
1 ms |
348 KB |
ok |
5 |
Correct |
1 ms |
344 KB |
ok |
6 |
Partially correct |
0 ms |
344 KB |
partial |
7 |
Incorrect |
0 ms |
344 KB |
wrong |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
0 ms |
344 KB |
partial |
2 |
Correct |
0 ms |
344 KB |
ok |
3 |
Correct |
0 ms |
348 KB |
ok |
4 |
Correct |
1 ms |
348 KB |
ok |
5 |
Correct |
1 ms |
344 KB |
ok |
6 |
Partially correct |
0 ms |
344 KB |
partial |
7 |
Incorrect |
0 ms |
344 KB |
wrong |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
0 ms |
344 KB |
partial |
2 |
Correct |
0 ms |
344 KB |
ok |
3 |
Correct |
0 ms |
348 KB |
ok |
4 |
Correct |
1 ms |
348 KB |
ok |
5 |
Correct |
1 ms |
344 KB |
ok |
6 |
Correct |
0 ms |
344 KB |
ok |
7 |
Partially correct |
0 ms |
344 KB |
partial |
8 |
Partially correct |
1 ms |
2648 KB |
partial |
9 |
Partially correct |
16 ms |
6492 KB |
partial |
10 |
Partially correct |
249 ms |
47400 KB |
partial |
11 |
Partially correct |
0 ms |
344 KB |
partial |
12 |
Incorrect |
0 ms |
344 KB |
wrong |
13 |
Halted |
0 ms |
0 KB |
- |