#include "soccer.h"
using namespace std;
#include <bits/stdc++.h>
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
#define ALL(x) (x).begin(), x.end()
vvi f;
int n;
int TTO(int x, int y)
{
return y * n + x;
}
ii OTT(int xy)
{
return {xy % n, xy / n};
}
bool works(const vb &pos)
{
for (int i = 0; i < n * n; i++)
{
if (!pos[i])
continue;
for (int j = 0; j < n * n; j++)
{
if (!pos[j] || j < i) // remove is problems
continue;
auto [x1, y1] = OTT(i);
auto [x2, y2] = OTT(j);
if (f[x1][y1] || f[x2][y2])
throw;
int x = x1, y = y1;
bool path1 = true;
int yD = y2 > y1 ? 1 : -1;
int xD = x2 > x1 ? 1 : -1;
while (x != x2)
{
x += xD;
if (f[x][y])
{
path1 = false;
break;
}
}
while (path1 && y != y2)
{
y += yD;
if (f[x][y])
{
path1 = false;
break;
}
}
if (path1)
continue;
x = x1, y = y1;
while (y != y2)
{
y += yD;
if (f[x][y])
{
return false;
}
}
while (x != x2)
{
x += xD;
if (f[x][y])
{
return false;
}
}
}
}
return true;
}
using namespace chrono;
int biggest_stadium(int N, vvi F)
{
auto t1 = std::chrono::high_resolution_clock::now();
n = N;
f = F;
int trees = 0;
vector<bool> all(N * N);
for (int x = 0; x < n; x++)
{
for (int y = 0; y < n; y++)
{
if (F[x][y])
trees++;
else
all[TTO(x, y)] = 1;
}
}
if (works(all))
return N * N - trees;
{
auto t2 = std::chrono::high_resolution_clock::now();
std::chrono::duration<double, std::milli> fp_ms = t2 - t1;
// cerr << fp_ms.count() << endl;
if (fp_ms.count() > 3000)
return 1;
}
vector<bool> pos(N * N);
for (int c = N * N - trees; c >= 2; c--)
{
pos.assign(N * N, 0);
for (int i = 0; i < c; i++)
{
pos[N * N - 1 - i] = 1;
}
do
{
auto t2 = std::chrono::high_resolution_clock::now();
std::chrono::duration<double, std::milli> fp_ms = t2 - t1;
// cerr << fp_ms.count() << endl;
if (fp_ms.count() > 2000)
return 1;
int posi = true;
for (int i = 0; i < N * N; i++)
{
if (pos[i])
{
auto [x, y] = OTT(i);
if (F[x][y])
{
posi = false;
break;
}
}
}
if (!posi)
continue;
if (works(pos))
return c;
} while (next_permutation(ALL(pos)));
}
return 1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
348 KB |
ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
ok |
2 |
Correct |
0 ms |
348 KB |
ok |
3 |
Correct |
0 ms |
348 KB |
ok |
4 |
Correct |
1 ms |
348 KB |
ok |
5 |
Correct |
0 ms |
348 KB |
ok |
6 |
Partially correct |
1 ms |
348 KB |
partial |
7 |
Partially correct |
1985 ms |
552 KB |
partial |
8 |
Execution timed out |
4503 ms |
3668 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
ok |
2 |
Correct |
0 ms |
348 KB |
ok |
3 |
Correct |
0 ms |
432 KB |
ok |
4 |
Correct |
1 ms |
348 KB |
ok |
5 |
Correct |
0 ms |
348 KB |
ok |
6 |
Correct |
0 ms |
348 KB |
ok |
7 |
Correct |
0 ms |
348 KB |
ok |
8 |
Correct |
0 ms |
348 KB |
ok |
9 |
Correct |
0 ms |
348 KB |
ok |
10 |
Correct |
1 ms |
348 KB |
ok |
11 |
Correct |
0 ms |
348 KB |
ok |
12 |
Correct |
0 ms |
348 KB |
ok |
13 |
Correct |
0 ms |
344 KB |
ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
348 KB |
ok |
2 |
Correct |
0 ms |
348 KB |
ok |
3 |
Correct |
0 ms |
348 KB |
ok |
4 |
Correct |
0 ms |
432 KB |
ok |
5 |
Correct |
1 ms |
348 KB |
ok |
6 |
Correct |
0 ms |
348 KB |
ok |
7 |
Correct |
0 ms |
348 KB |
ok |
8 |
Correct |
0 ms |
348 KB |
ok |
9 |
Correct |
0 ms |
348 KB |
ok |
10 |
Correct |
0 ms |
348 KB |
ok |
11 |
Correct |
1 ms |
348 KB |
ok |
12 |
Correct |
0 ms |
348 KB |
ok |
13 |
Correct |
0 ms |
348 KB |
ok |
14 |
Correct |
0 ms |
344 KB |
ok |
15 |
Partially correct |
124 ms |
412 KB |
partial |
16 |
Partially correct |
1990 ms |
592 KB |
partial |
17 |
Partially correct |
1983 ms |
416 KB |
partial |
18 |
Partially correct |
1974 ms |
412 KB |
partial |
19 |
Partially correct |
1981 ms |
408 KB |
partial |
20 |
Correct |
1 ms |
348 KB |
ok |
21 |
Correct |
0 ms |
348 KB |
ok |
22 |
Partially correct |
1990 ms |
412 KB |
partial |
23 |
Partially correct |
1987 ms |
596 KB |
partial |
24 |
Partially correct |
1968 ms |
412 KB |
partial |
25 |
Partially correct |
1973 ms |
412 KB |
partial |
26 |
Partially correct |
1983 ms |
412 KB |
partial |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
348 KB |
ok |
2 |
Correct |
0 ms |
348 KB |
ok |
3 |
Correct |
0 ms |
348 KB |
ok |
4 |
Correct |
0 ms |
348 KB |
ok |
5 |
Correct |
1 ms |
348 KB |
ok |
6 |
Correct |
0 ms |
432 KB |
ok |
7 |
Correct |
1 ms |
348 KB |
ok |
8 |
Correct |
0 ms |
348 KB |
ok |
9 |
Correct |
0 ms |
348 KB |
ok |
10 |
Correct |
0 ms |
348 KB |
ok |
11 |
Correct |
0 ms |
348 KB |
ok |
12 |
Correct |
0 ms |
348 KB |
ok |
13 |
Correct |
1 ms |
348 KB |
ok |
14 |
Correct |
0 ms |
348 KB |
ok |
15 |
Correct |
0 ms |
348 KB |
ok |
16 |
Correct |
0 ms |
344 KB |
ok |
17 |
Partially correct |
124 ms |
412 KB |
partial |
18 |
Partially correct |
1990 ms |
592 KB |
partial |
19 |
Partially correct |
1983 ms |
416 KB |
partial |
20 |
Partially correct |
1974 ms |
412 KB |
partial |
21 |
Partially correct |
1981 ms |
408 KB |
partial |
22 |
Correct |
1 ms |
348 KB |
ok |
23 |
Correct |
0 ms |
348 KB |
ok |
24 |
Partially correct |
1990 ms |
412 KB |
partial |
25 |
Partially correct |
1987 ms |
596 KB |
partial |
26 |
Partially correct |
1968 ms |
412 KB |
partial |
27 |
Partially correct |
1973 ms |
412 KB |
partial |
28 |
Partially correct |
1983 ms |
412 KB |
partial |
29 |
Partially correct |
1986 ms |
412 KB |
partial |
30 |
Partially correct |
1977 ms |
416 KB |
partial |
31 |
Partially correct |
1989 ms |
416 KB |
partial |
32 |
Partially correct |
1986 ms |
424 KB |
partial |
33 |
Partially correct |
1984 ms |
424 KB |
partial |
34 |
Correct |
1 ms |
348 KB |
ok |
35 |
Correct |
1 ms |
348 KB |
ok |
36 |
Partially correct |
1992 ms |
420 KB |
partial |
37 |
Partially correct |
1984 ms |
420 KB |
partial |
38 |
Partially correct |
1984 ms |
420 KB |
partial |
39 |
Partially correct |
1988 ms |
416 KB |
partial |
40 |
Partially correct |
1985 ms |
416 KB |
partial |
41 |
Partially correct |
1991 ms |
416 KB |
partial |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
348 KB |
ok |
2 |
Correct |
0 ms |
348 KB |
ok |
3 |
Correct |
0 ms |
348 KB |
ok |
4 |
Correct |
0 ms |
348 KB |
ok |
5 |
Correct |
1 ms |
348 KB |
ok |
6 |
Correct |
0 ms |
432 KB |
ok |
7 |
Correct |
1 ms |
348 KB |
ok |
8 |
Correct |
0 ms |
348 KB |
ok |
9 |
Correct |
0 ms |
348 KB |
ok |
10 |
Correct |
0 ms |
348 KB |
ok |
11 |
Correct |
0 ms |
348 KB |
ok |
12 |
Correct |
0 ms |
348 KB |
ok |
13 |
Correct |
1 ms |
348 KB |
ok |
14 |
Correct |
0 ms |
348 KB |
ok |
15 |
Correct |
0 ms |
348 KB |
ok |
16 |
Correct |
0 ms |
344 KB |
ok |
17 |
Partially correct |
124 ms |
412 KB |
partial |
18 |
Partially correct |
1990 ms |
592 KB |
partial |
19 |
Partially correct |
1983 ms |
416 KB |
partial |
20 |
Partially correct |
1974 ms |
412 KB |
partial |
21 |
Partially correct |
1981 ms |
408 KB |
partial |
22 |
Correct |
1 ms |
348 KB |
ok |
23 |
Correct |
0 ms |
348 KB |
ok |
24 |
Partially correct |
1990 ms |
412 KB |
partial |
25 |
Partially correct |
1987 ms |
596 KB |
partial |
26 |
Partially correct |
1968 ms |
412 KB |
partial |
27 |
Partially correct |
1973 ms |
412 KB |
partial |
28 |
Partially correct |
1983 ms |
412 KB |
partial |
29 |
Partially correct |
1986 ms |
412 KB |
partial |
30 |
Partially correct |
1977 ms |
416 KB |
partial |
31 |
Partially correct |
1989 ms |
416 KB |
partial |
32 |
Partially correct |
1986 ms |
424 KB |
partial |
33 |
Partially correct |
1984 ms |
424 KB |
partial |
34 |
Correct |
1 ms |
348 KB |
ok |
35 |
Correct |
1 ms |
348 KB |
ok |
36 |
Partially correct |
1992 ms |
420 KB |
partial |
37 |
Partially correct |
1984 ms |
420 KB |
partial |
38 |
Partially correct |
1984 ms |
420 KB |
partial |
39 |
Partially correct |
1988 ms |
416 KB |
partial |
40 |
Partially correct |
1985 ms |
416 KB |
partial |
41 |
Partially correct |
1991 ms |
416 KB |
partial |
42 |
Partially correct |
1996 ms |
3944 KB |
partial |
43 |
Partially correct |
2001 ms |
4184 KB |
partial |
44 |
Partially correct |
2004 ms |
3952 KB |
partial |
45 |
Partially correct |
2001 ms |
3944 KB |
partial |
46 |
Partially correct |
2001 ms |
3932 KB |
partial |
47 |
Partially correct |
2009 ms |
3948 KB |
partial |
48 |
Execution timed out |
4539 ms |
3848 KB |
Time limit exceeded |
49 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
348 KB |
ok |
2 |
Correct |
0 ms |
348 KB |
ok |
3 |
Correct |
0 ms |
348 KB |
ok |
4 |
Correct |
0 ms |
348 KB |
ok |
5 |
Correct |
1 ms |
348 KB |
ok |
6 |
Correct |
0 ms |
348 KB |
ok |
7 |
Partially correct |
1 ms |
348 KB |
partial |
8 |
Partially correct |
1985 ms |
552 KB |
partial |
9 |
Execution timed out |
4503 ms |
3668 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |