Submission #967560

# Submission time Handle Problem Language Result Execution time Memory
967560 2024-04-22T12:38:22 Z happy_node Amusement Park (JOI17_amusement_park) C++17
10 / 100
246 ms 262144 KB
#include "Joi.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

const int MX=10005;

vector<int> adj[MX];

int timer=-1;
vector<int> euler;
int sz[MX], par[MX], tin[MX], tout[MX];

void dfs(int v, int p) {
        tin[v]=++timer;
        euler.push_back(tin[v]);
        sz[v]=1;
        par[v]=p;
        for(auto u:adj[v]) {
                if(u==p) continue;
                dfs(u,v);
                sz[v]+=sz[u];
        }
        tout[v]=timer;
}

void Joi(int N, int M, int A[], int B[], long long X, int T) {
        for(int i=0;i<N-1;i++) {
                adj[A[i]].push_back(B[i]);
                adj[B[i]].push_back(A[i]);
        }

        dfs(0,-1);

        for(int i=0;i<N;i++) {
                int k=i%60;
                MessageBoard(euler[i],X>>k&1);
        }
}
#include "Ioi.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

const int MX=10005;

vector<int> adj[MX];

int timer=-1;
vector<int> euler;
int sz[MX], par[MX], tin[MX], tout[MX];

void dfs(int v, int p) {
        tin[v]=++timer;
        euler.push_back(tin[v]);
        sz[v]=1;
        par[v]=p;
        for(auto u:adj[v]) {
                if(u==p) continue;
                dfs(u,v);
                sz[v]+=sz[u];
        }
        tout[v]=timer;
}

ll get(int x, int y) {
        return y*(1LL<<(tin[x]%60));
}

ll res=0, cnt=0;

bool vis[60];

void dfs0(int v, int p) {
        if(cnt==60) return;
        for(auto u:adj[v]) {
                if(u==p) continue;
                if(!vis[tin[u]%60]) cnt++;
                vis[tin[u]%60]=1;
                res|=get(u,Move(u));
                dfs0(u,v);
                if(cnt==60) return;
                Move(v);
        }
}

long long Ioi(int N, int M, int A[], int B[], int P, int V, int T) {
        for(int i=0;i<N-1;i++) {
                adj[A[i]].push_back(B[i]);
                adj[B[i]].push_back(A[i]);
        }

        dfs(0,-1);

        int k=V;
        while(sz[P]<60) {
                P=par[P];
                k=Move(P);
        }

        res|=get(P,k);
        cnt++;
        vis[tin[P]%60]=1;
        dfs0(P,par[P]);

        return res;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1304 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 246 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1292 KB Output is correct
2 Correct 1 ms 1308 KB Output is correct
3 Correct 1 ms 1308 KB Output is correct
4 Correct 2 ms 1844 KB Output is correct
5 Correct 2 ms 1852 KB Output is correct
6 Correct 2 ms 1860 KB Output is correct
7 Correct 2 ms 1860 KB Output is correct
8 Correct 2 ms 1856 KB Output is correct
9 Correct 9 ms 4928 KB Output is correct
10 Correct 9 ms 4892 KB Output is correct
11 Correct 9 ms 4932 KB Output is correct
12 Correct 1 ms 1300 KB Output is correct
13 Correct 0 ms 1304 KB Output is correct
14 Correct 1 ms 1312 KB Output is correct
15 Correct 1 ms 1396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 216 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 207 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -