Submission #839787

# Submission time Handle Problem Language Result Execution time Memory
839787 2023-08-30T15:51:25 Z model_code Soccer Stadium (IOI23_soccer) C++17
12 / 100
4500 ms 33704 KB
// time_limit/iterative_closure.cpp

#include "soccer.h"
#include <iostream>
int n;
std::vector<std::vector<int>> c;
std::vector<std::vector<int>> pre;
std::vector<std::vector<int>> st;

int sum(int a, int b, int x, int y)
{
    if (a > x)
        std::swap(a, x);
    if (b > y)
        std::swap(b, y);
    return pre[x][y] - (b ? pre[x][b - 1] : 0) - (a ? pre[a - 1][y] : 0) + (a && b ? pre[a - 1][b - 1] : 0);
}

bool connected(int a, int b, int x, int y)
{
    return sum(a, b, x, b) + sum(x, b, x, y) == 0 || sum(a, b, a, y) + sum(a, y, x, y) == 0;
}

std::vector<std::pair<int, int>> curr;
int mx = 0;
void dfs(int x, int y)
{
    if (c[x][y] || st[x][y])
        return;

    st[x][y] = 1;
    bool ok = true;
    for (auto i : curr)
    {
        ok &= connected(i.first, i.second, x, y);
    }

    if (ok)
        curr.push_back({x, y});
    else
    {
        curr = {{x, y}};
    }

    mx = std::max(mx, (int)curr.size());

    if (x > 0)
        dfs(x - 1, y);
    if (y > 0)
        dfs(x, y - 1);
    if (y + 1 < n)
        dfs(x, y + 1);
    if (x + 1 < n)
        dfs(x + 1, y);
}

int biggest_stadium(int N, std::vector<std::vector<int>> C)
{
    n = N;
    c = C;
    pre.assign(n, std::vector<int>(n, 0));
    st.assign(n, std::vector<int>(n, 0));
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < n; ++j)
        {
            pre[i][j] = c[i][j];
            if (i)
                pre[i][j] += pre[i - 1][j];
            if (j)
                pre[i][j] += pre[i][j - 1];
            if (i && j)
                pre[i][j] -= pre[i - 1][j - 1];
        }
    }

    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < n; ++j)
        {
            dfs(i, j);
        }
    }

    return mx;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB partial
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB ok
2 Correct 0 ms 296 KB ok
3 Correct 0 ms 300 KB ok
4 Correct 0 ms 212 KB ok
5 Correct 0 ms 212 KB ok
6 Correct 1 ms 212 KB ok
7 Partially correct 167 ms 1796 KB partial
8 Execution timed out 4510 ms 10308 KB Time limit exceeded
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB ok
2 Correct 0 ms 296 KB ok
3 Partially correct 0 ms 212 KB partial
4 Correct 0 ms 212 KB ok
5 Correct 0 ms 212 KB ok
6 Correct 0 ms 212 KB ok
7 Partially correct 0 ms 212 KB partial
8 Correct 0 ms 212 KB ok
9 Correct 0 ms 212 KB ok
10 Correct 0 ms 212 KB ok
11 Correct 0 ms 212 KB ok
12 Correct 0 ms 212 KB ok
13 Correct 1 ms 212 KB ok
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB partial
2 Correct 0 ms 212 KB ok
3 Correct 0 ms 296 KB ok
4 Partially correct 0 ms 212 KB partial
5 Correct 0 ms 212 KB ok
6 Correct 0 ms 212 KB ok
7 Correct 0 ms 212 KB ok
8 Partially correct 0 ms 212 KB partial
9 Correct 0 ms 212 KB ok
10 Correct 0 ms 212 KB ok
11 Correct 0 ms 212 KB ok
12 Correct 0 ms 212 KB ok
13 Correct 0 ms 212 KB ok
14 Correct 1 ms 212 KB ok
15 Partially correct 0 ms 212 KB partial
16 Partially correct 1 ms 212 KB partial
17 Partially correct 1 ms 212 KB partial
18 Correct 1 ms 300 KB ok
19 Partially correct 0 ms 212 KB partial
20 Correct 1 ms 212 KB ok
21 Correct 0 ms 212 KB ok
22 Partially correct 1 ms 212 KB partial
23 Partially correct 0 ms 212 KB partial
24 Partially correct 0 ms 212 KB partial
25 Correct 0 ms 212 KB ok
26 Partially correct 0 ms 212 KB partial
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB partial
2 Correct 0 ms 212 KB ok
3 Correct 0 ms 296 KB ok
4 Correct 0 ms 300 KB ok
5 Correct 0 ms 212 KB ok
6 Partially correct 0 ms 212 KB partial
7 Correct 0 ms 212 KB ok
8 Correct 0 ms 212 KB ok
9 Correct 0 ms 212 KB ok
10 Partially correct 0 ms 212 KB partial
11 Correct 0 ms 212 KB ok
12 Correct 0 ms 212 KB ok
13 Correct 0 ms 212 KB ok
14 Correct 0 ms 212 KB ok
15 Correct 0 ms 212 KB ok
16 Correct 1 ms 212 KB ok
17 Partially correct 0 ms 212 KB partial
18 Partially correct 1 ms 212 KB partial
19 Partially correct 1 ms 212 KB partial
20 Correct 1 ms 300 KB ok
21 Partially correct 0 ms 212 KB partial
22 Correct 1 ms 212 KB ok
23 Correct 0 ms 212 KB ok
24 Partially correct 1 ms 212 KB partial
25 Partially correct 0 ms 212 KB partial
26 Partially correct 0 ms 212 KB partial
27 Correct 0 ms 212 KB ok
28 Partially correct 0 ms 212 KB partial
29 Partially correct 0 ms 212 KB partial
30 Partially correct 1 ms 340 KB partial
31 Partially correct 0 ms 340 KB partial
32 Partially correct 1 ms 212 KB partial
33 Correct 0 ms 212 KB ok
34 Correct 1 ms 300 KB ok
35 Correct 1 ms 340 KB ok
36 Partially correct 1 ms 212 KB partial
37 Partially correct 1 ms 212 KB partial
38 Partially correct 1 ms 340 KB partial
39 Partially correct 1 ms 340 KB partial
40 Correct 2 ms 340 KB ok
41 Partially correct 1 ms 340 KB partial
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB partial
2 Correct 0 ms 212 KB ok
3 Correct 0 ms 296 KB ok
4 Correct 0 ms 300 KB ok
5 Correct 0 ms 212 KB ok
6 Partially correct 0 ms 212 KB partial
7 Correct 0 ms 212 KB ok
8 Correct 0 ms 212 KB ok
9 Correct 0 ms 212 KB ok
10 Partially correct 0 ms 212 KB partial
11 Correct 0 ms 212 KB ok
12 Correct 0 ms 212 KB ok
13 Correct 0 ms 212 KB ok
14 Correct 0 ms 212 KB ok
15 Correct 0 ms 212 KB ok
16 Correct 1 ms 212 KB ok
17 Partially correct 0 ms 212 KB partial
18 Partially correct 1 ms 212 KB partial
19 Partially correct 1 ms 212 KB partial
20 Correct 1 ms 300 KB ok
21 Partially correct 0 ms 212 KB partial
22 Correct 1 ms 212 KB ok
23 Correct 0 ms 212 KB ok
24 Partially correct 1 ms 212 KB partial
25 Partially correct 0 ms 212 KB partial
26 Partially correct 0 ms 212 KB partial
27 Correct 0 ms 212 KB ok
28 Partially correct 0 ms 212 KB partial
29 Partially correct 0 ms 212 KB partial
30 Partially correct 1 ms 340 KB partial
31 Partially correct 0 ms 340 KB partial
32 Partially correct 1 ms 212 KB partial
33 Correct 0 ms 212 KB ok
34 Correct 1 ms 300 KB ok
35 Correct 1 ms 340 KB ok
36 Partially correct 1 ms 212 KB partial
37 Partially correct 1 ms 212 KB partial
38 Partially correct 1 ms 340 KB partial
39 Partially correct 1 ms 340 KB partial
40 Correct 2 ms 340 KB ok
41 Partially correct 1 ms 340 KB partial
42 Partially correct 65 ms 27908 KB partial
43 Partially correct 51 ms 21748 KB partial
44 Partially correct 104 ms 33308 KB partial
45 Partially correct 123 ms 33704 KB partial
46 Partially correct 67 ms 31260 KB partial
47 Execution timed out 4525 ms 14572 KB Time limit exceeded
48 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB partial
2 Correct 0 ms 212 KB ok
3 Correct 0 ms 296 KB ok
4 Correct 0 ms 300 KB ok
5 Correct 0 ms 212 KB ok
6 Correct 0 ms 212 KB ok
7 Correct 1 ms 212 KB ok
8 Partially correct 167 ms 1796 KB partial
9 Execution timed out 4510 ms 10308 KB Time limit exceeded
10 Halted 0 ms 0 KB -