Submission #1069811

# Submission time Handle Problem Language Result Execution time Memory
1069811 2024-08-22T09:07:04 Z juicy None (JOI16_dungeon2) C++17
90 / 100
14 ms 1372 KB
#include "dungeon2.h"

#include <bits/stdc++.h>

using namespace std;

namespace {
    const int N = 200, LG = 5;

    int n;
    int d[N][N], deg[N], res[N];
    vector<array<int, 2>> tree[N], back[N];

    void init() {
        int u = n++;
        deg[u] = NumberOfRoads();
        for (int i = 1; i <= deg[u]; ++i) {
            Move(i, 2);
            int c = Color();
            int ind = LastRoad();
            if (c == 1) {
                tree[u].push_back({n, i});
                init();
                Move(ind, 3);
            } else if (c == 2) {
                back[u].push_back({i, 0});
                Move(ind, 2);
            } else {
                Move(ind, 3);
            }
        }
    }

    void dfs(int u, int x) {
        int c = (u / x) % 3 + 1;
        for (auto &[v, ind] : back[u]) {
            Move(v, c);
            int w = Color();
            ind += (w - 1) * x;
            Move(LastRoad(), w);
        }
        for (auto [v, ind] : tree[u]) {
            Move(ind, c);
            int i = LastRoad();
            dfs(v, x);
            Move(i, 3);
        }
    }
}

void Inspect(int R) {
    init();
    for (int i = 1, j = 0; j < 5; i *= 3, ++j) {
        dfs(0, i);
    }
    for (int i = 0; i < n; ++i) {
        fill(d[i], d[i] + n, N + 1);
        d[i][i] = 0;
        for (auto [j, ind] : tree[i]) {
            d[i][j] = d[j][i] = 1;
        }
        for (auto [ind, j] : back[i]) {
            d[i][j] = d[j][i] = 1;
        }
    }
    for (int k = 0; k < n; ++k) {
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            if (d[i][j] <= R) {
                ++res[d[i][j] - 1];
            }
        }
    }
    for (int i = 1; i <= R; ++i) {
        Answer(i, res[i - 1]);
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 452 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 448 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 604 KB Output is correct
10 Correct 0 ms 604 KB Output is correct
11 Correct 0 ms 460 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 0 ms 604 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 0 ms 448 KB Output is correct
10 Correct 0 ms 604 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 556 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 604 KB Output is correct
15 Correct 0 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 8 ms 860 KB Partially correct
2 Partially correct 12 ms 860 KB Partially correct
3 Partially correct 8 ms 860 KB Partially correct
4 Partially correct 14 ms 1372 KB Partially correct
5 Partially correct 1 ms 604 KB Partially correct
6 Partially correct 2 ms 832 KB Partially correct
7 Partially correct 8 ms 860 KB Partially correct
8 Partially correct 8 ms 1032 KB Partially correct
9 Partially correct 8 ms 860 KB Partially correct
10 Partially correct 8 ms 860 KB Partially correct
11 Partially correct 10 ms 860 KB Partially correct
12 Partially correct 8 ms 860 KB Partially correct
13 Partially correct 9 ms 1116 KB Partially correct
14 Partially correct 8 ms 1024 KB Partially correct
15 Partially correct 8 ms 860 KB Partially correct
16 Partially correct 3 ms 776 KB Partially correct
17 Partially correct 14 ms 1372 KB Partially correct
18 Partially correct 13 ms 1232 KB Partially correct
19 Partially correct 13 ms 1368 KB Partially correct