#include "soccer.h"
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
#define f first
#define s second
int biggest_stadium(int N, vector<vector<int>> F)
{
vector<vector<int>> prefixLine(N), prefixCol(N);
for (int i = 0; i < N; i++)
{
prefixLine[i] = vector<int>(N, 0);
prefixLine[i][0] = F[i][0];
for (int j = 1; j < N; j++)
{
prefixLine[i][j] = prefixLine[i][j - 1] + F[i][j];
}
}
for (int i = 0; i < N; i++)
{
prefixCol[i] = vector<int>(N, 0);
prefixCol[i][0] = F[0][i];
for (int j = 1; j < N; j++)
{
prefixCol[i][j] = prefixCol[i][j - 1] + F[j][i];
}
}
set<pii> freeCells;
for (int i = 0; i < N; i++)
{
for (int j = 0; j < N; j++)
{
if (F[i][j] == 0)
{
freeCells.insert({i, j});
}
}
}
bool possible = true;
for (pii p1 : freeCells)
{
for (pii p2 : freeCells)
{
if (p1 == p2)
continue;
if (p1.f == p2.f)
{
int sum = prefixLine[p1.f][max(p1.s, p2.s)];
if (min(p1.s, p2.s) > 0)
{
sum -= prefixLine[p1.f][min(p1.s, p2.s) - 1];
}
if (sum != 0)
{
//cout << "{" << p1.f << ", " << p1.s << "} - {" << p2.f << ", " << p2.s << "}\n";
possible = false;
break;
}
}
else if (p1.s == p2.s)
{
int sum = prefixCol[p1.s][max(p1.f, p2.f)];
if (min(p1.f, p2.f) > 0)
{
sum -= prefixCol[p1.s][min(p1.f, p2.f) - 1];
}
if (sum != 0)
{
//cout << "{" << p1.f << ", " << p1.s << "} - {" << p2.f << ", " << p2.s << "}\n";
possible = false;
break;
}
}
else
{
// cout << "check {" << p1.f << ", " << p1.s << "} - {" << p2.f << ", " << p2.s << "}\n";
int sum1 = prefixLine[p1.f][max(p1.s, p2.s)] + prefixCol[p2.s][max(p1.f, p2.f)];
int sum2 = prefixLine[p2.f][max(p1.s, p2.s)] + prefixCol[p1.s][max(p1.f, p2.f)];
if (min(p1.s, p2.s) > 0)
{
sum1 -= prefixLine[p1.f][min(p1.s, p2.s) - 1];
sum2 -= prefixLine[p2.f][min(p1.s, p2.s) - 1];
}
if (min(p1.f, p2.f) > 0)
{
sum1 -= prefixCol[p2.s][min(p1.f, p2.f) - 1];
sum2 -= prefixCol[p1.s][min(p1.f, p2.f) - 1];
}
// cout << "sums: " << sum1 << " " << sum2 << '\n';
// cout << "s1: " << prefixLine[p1.f][max(p1.s, p2.s)] - prefixLine[p1.f][min(p1.s, p2.s)] << '\n';
if (sum1 != 0 && sum2 != 0)
{
// cout << "{" << p1.f << ", " << p1.s << "} - {" << p2.f << ", " << p2.s << "}\n";
possible = false;
break;
}
}
}
if (!possible)
break;
}
if (possible)
{
return freeCells.size();
}
else
{
return 0;
}
}
# |
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 |
344 KB |
ok |
3 |
Correct |
0 ms |
348 KB |
ok |
4 |
Correct |
0 ms |
348 KB |
ok |
5 |
Correct |
1 ms |
344 KB |
ok |
6 |
Partially correct |
0 ms |
348 KB |
partial |
7 |
Partially correct |
10 ms |
1064 KB |
partial |
8 |
Partially correct |
505 ms |
16140 KB |
partial |
9 |
Execution timed out |
4537 ms |
250972 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
ok |
2 |
Correct |
0 ms |
344 KB |
ok |
3 |
Partially correct |
0 ms |
344 KB |
partial |
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 |
348 KB |
partial |
8 |
Correct |
0 ms |
348 KB |
ok |
9 |
Correct |
0 ms |
348 KB |
ok |
10 |
Partially correct |
1 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 |
# |
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 |
344 KB |
ok |
4 |
Partially correct |
0 ms |
344 KB |
partial |
5 |
Partially correct |
0 ms |
348 KB |
partial |
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 |
Correct |
0 ms |
348 KB |
ok |
10 |
Correct |
0 ms |
348 KB |
ok |
11 |
Partially correct |
1 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 |
344 KB |
partial |
18 |
Partially correct |
0 ms |
348 KB |
partial |
19 |
Partially correct |
0 ms |
348 KB |
partial |
20 |
Correct |
0 ms |
348 KB |
ok |
21 |
Correct |
0 ms |
348 KB |
ok |
22 |
Partially correct |
0 ms |
348 KB |
partial |
23 |
Partially correct |
0 ms |
348 KB |
partial |
24 |
Partially correct |
0 ms |
348 KB |
partial |
25 |
Partially correct |
0 ms |
348 KB |
partial |
26 |
Partially correct |
0 ms |
348 KB |
partial |
# |
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 |
344 KB |
ok |
4 |
Correct |
0 ms |
348 KB |
ok |
5 |
Correct |
0 ms |
348 KB |
ok |
6 |
Partially correct |
0 ms |
344 KB |
partial |
7 |
Partially correct |
0 ms |
348 KB |
partial |
8 |
Partially correct |
0 ms |
348 KB |
partial |
9 |
Partially correct |
0 ms |
348 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 |
1 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 |
344 KB |
partial |
20 |
Partially correct |
0 ms |
348 KB |
partial |
21 |
Partially correct |
0 ms |
348 KB |
partial |
22 |
Correct |
0 ms |
348 KB |
ok |
23 |
Correct |
0 ms |
348 KB |
ok |
24 |
Partially correct |
0 ms |
348 KB |
partial |
25 |
Partially correct |
0 ms |
348 KB |
partial |
26 |
Partially correct |
0 ms |
348 KB |
partial |
27 |
Partially correct |
0 ms |
348 KB |
partial |
28 |
Partially correct |
0 ms |
348 KB |
partial |
29 |
Partially correct |
0 ms |
348 KB |
partial |
30 |
Partially correct |
1 ms |
348 KB |
partial |
31 |
Partially correct |
0 ms |
348 KB |
partial |
32 |
Partially correct |
0 ms |
348 KB |
partial |
33 |
Partially correct |
0 ms |
348 KB |
partial |
34 |
Correct |
0 ms |
348 KB |
ok |
35 |
Correct |
1 ms |
348 KB |
ok |
36 |
Partially correct |
1 ms |
604 KB |
partial |
37 |
Partially correct |
1 ms |
432 KB |
partial |
38 |
Partially correct |
1 ms |
348 KB |
partial |
39 |
Partially correct |
0 ms |
348 KB |
partial |
40 |
Partially correct |
1 ms |
344 KB |
partial |
41 |
Partially correct |
1 ms |
348 KB |
partial |
# |
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 |
344 KB |
ok |
4 |
Correct |
0 ms |
348 KB |
ok |
5 |
Correct |
0 ms |
348 KB |
ok |
6 |
Partially correct |
0 ms |
344 KB |
partial |
7 |
Partially correct |
0 ms |
348 KB |
partial |
8 |
Partially correct |
0 ms |
348 KB |
partial |
9 |
Partially correct |
0 ms |
348 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 |
1 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 |
344 KB |
partial |
20 |
Partially correct |
0 ms |
348 KB |
partial |
21 |
Partially correct |
0 ms |
348 KB |
partial |
22 |
Correct |
0 ms |
348 KB |
ok |
23 |
Correct |
0 ms |
348 KB |
ok |
24 |
Partially correct |
0 ms |
348 KB |
partial |
25 |
Partially correct |
0 ms |
348 KB |
partial |
26 |
Partially correct |
0 ms |
348 KB |
partial |
27 |
Partially correct |
0 ms |
348 KB |
partial |
28 |
Partially correct |
0 ms |
348 KB |
partial |
29 |
Partially correct |
0 ms |
348 KB |
partial |
30 |
Partially correct |
1 ms |
348 KB |
partial |
31 |
Partially correct |
0 ms |
348 KB |
partial |
32 |
Partially correct |
0 ms |
348 KB |
partial |
33 |
Partially correct |
0 ms |
348 KB |
partial |
34 |
Correct |
0 ms |
348 KB |
ok |
35 |
Correct |
1 ms |
348 KB |
ok |
36 |
Partially correct |
1 ms |
604 KB |
partial |
37 |
Partially correct |
1 ms |
432 KB |
partial |
38 |
Partially correct |
1 ms |
348 KB |
partial |
39 |
Partially correct |
0 ms |
348 KB |
partial |
40 |
Partially correct |
1 ms |
344 KB |
partial |
41 |
Partially correct |
1 ms |
348 KB |
partial |
42 |
Partially correct |
52 ms |
15440 KB |
partial |
43 |
Partially correct |
46 ms |
14152 KB |
partial |
44 |
Partially correct |
57 ms |
16392 KB |
partial |
45 |
Partially correct |
56 ms |
16536 KB |
partial |
46 |
Partially correct |
53 ms |
15956 KB |
partial |
47 |
Partially correct |
55 ms |
16628 KB |
partial |
48 |
Execution timed out |
4564 ms |
10580 KB |
Time limit exceeded |
49 |
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 |
344 KB |
ok |
4 |
Correct |
0 ms |
348 KB |
ok |
5 |
Correct |
0 ms |
348 KB |
ok |
6 |
Correct |
1 ms |
344 KB |
ok |
7 |
Partially correct |
0 ms |
348 KB |
partial |
8 |
Partially correct |
10 ms |
1064 KB |
partial |
9 |
Partially correct |
505 ms |
16140 KB |
partial |
10 |
Execution timed out |
4537 ms |
250972 KB |
Time limit exceeded |
11 |
Halted |
0 ms |
0 KB |
- |