Submission #401857

# Submission time Handle Problem Language Result Execution time Memory
401857 2021-05-10T22:02:13 Z timmyfeng Amusement Park (JOI17_amusement_park) C++17
18 / 100
30 ms 3412 KB
#include <bits/stdc++.h>
using namespace std;
 
#include "Joi.h"
 
void Joi(int n, int m, int *a, int *b, long long x, int t) {
    vector<vector<int>> adj(n);
    for (int i = 0; i < m; ++i) {
        adj[a[i]].push_back(b[i]);
        adj[b[i]].push_back(a[i]);
    }
 
    vector<bool> visited(n);
    auto dfs = [&](int u, auto &self) -> void {
        MessageBoard(u, x % 2);
        x /= 2;
 
        visited[u] = true;
        for (auto c : adj[u]) {
            if (!visited[c]) {
                self(c, self);
            }
        }
    };
 
    dfs(0, dfs);
}
#include <bits/stdc++.h>
using namespace std;
 
#include "Ioi.h"
 
const int L = 60;
 
long long Ioi(int n, int m, int *a, int *b, int p, int v, int t) {
    vector<vector<int>> adj(n);
    for (int i = 0; i < m; ++i) {
        adj[a[i]].push_back(b[i]);
        adj[b[i]].push_back(a[i]);
    }
 
    vector<int> path;
    vector<bool> visited(n);
    auto dfs_find = [&](int u, auto &self) -> bool {
        visited[u] = true;
        if (u == 0) {
            return true;
        }
 
        for (auto c : adj[u]) {
            if (!visited[c] && self(c, self)) {
                path.push_back(c);
                return true;
            }
        }
        return false;
    };
 
    dfs_find(p, dfs_find);
 
    reverse(path.begin(), path.end());
 
    for (auto u : path) {
        v = Move(u);
    }
 
    long long ans = 0, bit = 1;
    visited.assign(n, false);
    auto dfs_read = [&](int u, auto &self) -> bool {
        ans += v * bit;
        bit *= 2;
 
        if (__lg(bit) == L) {
            return true;
        }
 
        visited[u] = true;
        for (auto c : adj[u]) {
            if (!visited[c]) {
                v = Move(c);
                if (self(c, self)) {
                    return true;
                }
                v = Move(u);
            }
        }
        return false;
    };
 
    dfs_read(0, dfs_read);
 
    return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 488 KB Output is correct
2 Correct 2 ms 496 KB Output is correct
3 Correct 2 ms 620 KB Output is correct
4 Correct 2 ms 488 KB Output is correct
5 Correct 2 ms 488 KB Output is correct
6 Correct 2 ms 496 KB Output is correct
7 Correct 2 ms 628 KB Output is correct
8 Correct 2 ms 748 KB Output is correct
9 Correct 2 ms 492 KB Output is correct
10 Correct 2 ms 496 KB Output is correct
11 Correct 5 ms 928 KB Output is correct
12 Correct 2 ms 488 KB Output is correct
13 Correct 2 ms 620 KB Output is correct
14 Correct 2 ms 692 KB Output is correct
15 Correct 2 ms 748 KB Output is correct
16 Correct 2 ms 500 KB Output is correct
17 Correct 2 ms 752 KB Output is correct
18 Correct 2 ms 628 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 3344 KB Output is correct
2 Correct 26 ms 3412 KB Output is correct
3 Correct 26 ms 3140 KB Output is correct
4 Correct 16 ms 2236 KB Output is correct
5 Correct 15 ms 2584 KB Output is correct
6 Correct 16 ms 2492 KB Output is correct
7 Correct 15 ms 2484 KB Output is correct
8 Correct 15 ms 2356 KB Output is correct
9 Correct 18 ms 2520 KB Output is correct
10 Correct 16 ms 2496 KB Output is correct
11 Correct 16 ms 2500 KB Output is correct
12 Correct 14 ms 2104 KB Output is correct
13 Correct 14 ms 2216 KB Output is correct
14 Correct 16 ms 2236 KB Output is correct
15 Correct 18 ms 2224 KB Output is correct
16 Correct 14 ms 2264 KB Output is correct
17 Correct 19 ms 2316 KB Output is correct
18 Correct 18 ms 2248 KB Output is correct
19 Correct 15 ms 2260 KB Output is correct
20 Correct 12 ms 2488 KB Output is correct
21 Correct 14 ms 2416 KB Output is correct
22 Correct 15 ms 2468 KB Output is correct
23 Correct 16 ms 2352 KB Output is correct
24 Correct 14 ms 2468 KB Output is correct
25 Correct 15 ms 2484 KB Output is correct
26 Correct 16 ms 2472 KB Output is correct
27 Correct 16 ms 2460 KB Output is correct
28 Correct 16 ms 2524 KB Output is correct
29 Correct 14 ms 2228 KB Output is correct
30 Correct 14 ms 2360 KB Output is correct
31 Correct 2 ms 488 KB Output is correct
32 Correct 2 ms 488 KB Output is correct
33 Correct 2 ms 748 KB Output is correct
34 Correct 2 ms 500 KB Output is correct
35 Correct 2 ms 496 KB Output is correct
36 Correct 2 ms 488 KB Output is correct
37 Correct 2 ms 488 KB Output is correct
38 Correct 2 ms 488 KB Output is correct
39 Correct 2 ms 496 KB Output is correct
40 Correct 2 ms 504 KB Output is correct
41 Correct 2 ms 488 KB Output is correct
42 Correct 2 ms 488 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 488 KB Output is correct
2 Correct 2 ms 496 KB Output is correct
3 Correct 2 ms 488 KB Output is correct
4 Correct 3 ms 828 KB Output is correct
5 Incorrect 4 ms 844 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 30 ms 3320 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 25 ms 3268 KB Output isn't correct
2 Halted 0 ms 0 KB -