Submission #401858

# Submission time Handle Problem Language Result Execution time Memory
401858 2021-05-10T22:12:33 Z timmyfeng Amusement Park (JOI17_amusement_park) C++17
18 / 100
28 ms 3892 KB
#include <bits/stdc++.h>
using namespace std;
 
#include "Joi.h"

vector<vector<int>> adj_joi;
vector<bool> visited_joi;
long long x_joi;

void dfs(int u) {
    MessageBoard(u, x_joi % 2);
    x_joi /= 2;

    visited_joi[u] = true;
    for (auto c : adj_joi[u]) {
        if (!visited_joi[c]) {
            dfs(c);
        }
    }
}
 
void Joi(int n, int m, int *a, int *b, long long x, int t) {
    adj_joi.resize(n);
    visited_joi.resize(n);

    for (int i = 0; i < m; ++i) {
        adj_joi[a[i]].push_back(b[i]);
        adj_joi[b[i]].push_back(a[i]);
    }

    x_joi = x;

    dfs(0);
}
#include <bits/stdc++.h>
using namespace std;
 
#include "Ioi.h"
 
const int L = 60;

vector<vector<int>> adj_ioi;
long long ans_ioi, bit_ioi;
vector<bool> visited_ioi;
vector<int> path_ioi;
int v_ioi;

bool dfs_find(int u) {
    visited_ioi[u] = true;
    if (u == 0) {
        return true;
    }

    for (auto c : adj_ioi[u]) {
        if (!visited_ioi[c] && dfs_find(c)) {
            path_ioi.push_back(c);
            return true;
        }
    }
    return false;
}


bool dfs_read(int u) {
    ans_ioi += v_ioi * bit_ioi;
    bit_ioi *= 2;

    if (__lg(bit_ioi) == L) {
        return true;
    }

    visited_ioi[u] = true;
    for (auto c : adj_ioi[u]) {
        if (!visited_ioi[c]) {
            v_ioi = Move(c);
            if (dfs_read(c)) {
                return true;
            }
            v_ioi = Move(u);
        }
    }
    return false;
}
 
long long Ioi(int n, int m, int *a, int *b, int p, int v, int t) {
    adj_ioi.resize(n);
    visited_ioi.resize(n);

    for (int i = 0; i < m; ++i) {
        adj_ioi[a[i]].push_back(b[i]);
        adj_ioi[b[i]].push_back(a[i]);
    }
 
    dfs_find(p);
 
    v_ioi = v;
    reverse(path_ioi.begin(), path_ioi.end());
    for (auto u : path_ioi) {
        v_ioi = Move(u);
    }

    ans_ioi = 0, bit_ioi = 1;
    visited_ioi.assign(n, false);
 
    dfs_read(0);
 
    return ans_ioi;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 488 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
3 Correct 2 ms 624 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 488 KB Output is correct
7 Correct 2 ms 748 KB Output is correct
8 Correct 2 ms 756 KB Output is correct
9 Correct 2 ms 748 KB Output is correct
10 Correct 2 ms 488 KB Output is correct
11 Correct 5 ms 920 KB Output is correct
12 Correct 2 ms 488 KB Output is correct
13 Correct 2 ms 748 KB Output is correct
14 Correct 2 ms 748 KB Output is correct
15 Correct 2 ms 748 KB Output is correct
16 Correct 2 ms 620 KB Output is correct
17 Correct 2 ms 628 KB Output is correct
18 Correct 2 ms 728 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 3892 KB Output is correct
2 Correct 25 ms 3752 KB Output is correct
3 Correct 24 ms 3408 KB Output is correct
4 Correct 14 ms 2488 KB Output is correct
5 Correct 20 ms 3008 KB Output is correct
6 Correct 15 ms 2912 KB Output is correct
7 Correct 15 ms 2880 KB Output is correct
8 Correct 14 ms 2620 KB Output is correct
9 Correct 15 ms 2880 KB Output is correct
10 Correct 16 ms 2596 KB Output is correct
11 Correct 16 ms 2604 KB Output is correct
12 Correct 13 ms 2344 KB Output is correct
13 Correct 13 ms 2352 KB Output is correct
14 Correct 14 ms 2352 KB Output is correct
15 Correct 14 ms 2488 KB Output is correct
16 Correct 14 ms 2496 KB Output is correct
17 Correct 15 ms 2536 KB Output is correct
18 Correct 14 ms 2436 KB Output is correct
19 Correct 18 ms 2392 KB Output is correct
20 Correct 17 ms 2884 KB Output is correct
21 Correct 12 ms 2740 KB Output is correct
22 Correct 14 ms 2720 KB Output is correct
23 Correct 14 ms 2748 KB Output is correct
24 Correct 14 ms 2624 KB Output is correct
25 Correct 15 ms 2788 KB Output is correct
26 Correct 14 ms 2656 KB Output is correct
27 Correct 19 ms 2744 KB Output is correct
28 Correct 15 ms 2740 KB Output is correct
29 Correct 15 ms 2548 KB Output is correct
30 Correct 14 ms 2480 KB Output is correct
31 Correct 2 ms 496 KB Output is correct
32 Correct 2 ms 496 KB Output is correct
33 Correct 2 ms 748 KB Output is correct
34 Correct 2 ms 480 KB Output is correct
35 Correct 2 ms 488 KB Output is correct
36 Correct 2 ms 496 KB Output is correct
37 Correct 2 ms 492 KB Output is correct
38 Correct 2 ms 484 KB Output is correct
39 Correct 2 ms 496 KB Output is correct
40 Correct 2 ms 596 KB Output is correct
41 Correct 2 ms 496 KB Output is correct
42 Correct 2 ms 488 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 500 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
3 Correct 2 ms 488 KB Output is correct
4 Correct 3 ms 900 KB Output is correct
5 Incorrect 3 ms 1028 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 25 ms 3856 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 3660 KB Output isn't correct
2 Halted 0 ms 0 KB -