Submission #933712

# Submission time Handle Problem Language Result Execution time Memory
933712 2024-02-26T07:09:37 Z parlimoos Amusement Park (JOI17_amusement_park) C++14
100 / 100
22 ms 6868 KB
//‌Be Name KHODA
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include "Joi.h"
using namespace std;

typedef long long ll;
typedef long double ld;
#define pb push_back
#define pp pop_back
#define lb lower_bound
#define ub upper_bound
#define cl clear
#define bg begin
#define arr(x) array<int , x>
#define endl '\n'

vector<int> jg[10000] , jtr[10000];
int jh[10000] , jtms[10000] , cjh[10000];
int mxj[10000] , pj[10000];
bool jms[10000];

int jtimer = -1;
void jdfs1(int v = 0 , int p = -1){
    jms[v] = 1 , jh[v] = 1 , pj[v] = p;
    if(p != -1) cjh[v] = cjh[p] + 1;
    for(int u : jg[v]){
        if(jms[u]) continue;
        jtr[v].pb(u);
        jdfs1(u , v) , jh[v] = max(jh[v] , jh[u] + 1);
    }
}
void jdfs2(int v = 0){
    jtms[v] = ++jtimer , mxj[v] = -1;
    for(int u : jtr[v]) if(mxj[v] == -1 or jh[mxj[v]] < jh[u]) mxj[v] = u;
    if(mxj[v] == -1) return;
    jdfs2(mxj[v]);
    for(int u : jtr[v]) if(u != mxj[v]) jdfs2(u);
}
void Joi(int N , int M , int A[] , int B[] , ll X , int T){
    for(int i = 0 ; i < M ; i++) jg[A[i]].pb(B[i]) , jg[B[i]].pb(A[i]);
    jdfs1() , jdfs2();
    if(jh[0] >= 60){
        for(int i = 0 ; i < N ; i++) MessageBoard(i , int((X >> (cjh[i] % 60)) & 1ll));
    }else for(int i = 0 ; i < N ; i++) MessageBoard(i , int((X >> (jtms[i] % 60)) & 1ll));
}
//Be Name KHODA
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include "Ioi.h"
using namespace std;

typedef long long ll;
typedef long double ld;
#define pb push_back
#define pp pop_back
#define lb lower_bound
#define ub upper_bound
#define cl clear
#define bg begin
#define arr(x) array<int , x>
#define endl '\n'

int n;
vector<int> g[20000] , tr[20000];
int h[20000] , tms[20000] , ps[20000];
int ch[20000] , mxi[20000];
bool ms[20000];
ll o = 0;

int timer = -1;
void dfs1(int v = 0 , int p = -1){
    ms[v] = 1 , h[v] = 1 , ps[v] = p;
    if(p != -1) ch[v] = ch[p] + 1;
    for(int u : g[v]){
        if(ms[u]) continue;
        tr[v].pb(u);
        dfs1(u , v) , h[v] = max(h[v] , h[u] + 1);
    }
}
void dfs2(int v = 0){
    tms[v] = ++timer , mxi[v] = -1;
    for(int u : tr[v]) if(mxi[v] == -1 or h[mxi[v]] < h[u]) mxi[v] = u;
    if(mxi[v] == -1) return;
    dfs2(mxi[v]);
    for(int u : tr[v]) if(mxi[v] != u) dfs2(u);
}
void dfs3(int v , bool bb){
    for(int u : tr[v]){
        if(bb){
            if(u != mxi[v] and tms[u] < 60){
                ll d = Move(u);
                o |= (d << tms[u]);
                dfs3(u , 0);
                d = Move(v);
            }
        }else{
            if(tms[u] < 60){
                ll d = Move(u);
                o |= (d << tms[u]);
                dfs3(u , 0);
                d = Move(v);
            }
        }
    }
}
ll Ioi(int N , int M , int A[] , int B[] , int P , int V , int T){
    n = N;
    for(int i = 0 ; i < M ; i++) g[A[i]].pb(B[i]) , g[B[i]].pb(A[i]);
    dfs1() , dfs2();
    if(h[0] >= 60){
        if(ch[P] < 59){
            ll d = V;
            while(P != 0) d = Move(ps[P]) , P = ps[P];
            o = d;
            int i;
            for(i = 1 ; i < 60 ; i++){
                d = Move(mxi[P]) , P = mxi[P];
                o |= (d << i);
            }
        }else{
            o = ((1ll * V) << (ch[P] % 60));
            ll d;
            for(int i = 1 ; i < 60 ; i++){
                d = Move(ps[P]) , P = ps[P];
                o |= (d << (ch[P] % 60));
            }
        }
    }else{
        ll d = V;
        while(P != 0) d = Move(ps[P]) , P = ps[P];
        o = d;
        while(true){
            dfs3(P , 1);
            if(mxi[P] == -1) break;
            d = Move(mxi[P]) , P = mxi[P];
            o |= (d << tms[P]);
        }
    }
    return o;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2332 KB Output is correct
2 Correct 2 ms 2332 KB Output is correct
3 Correct 2 ms 2332 KB Output is correct
4 Correct 2 ms 2336 KB Output is correct
5 Correct 2 ms 2332 KB Output is correct
6 Correct 2 ms 2336 KB Output is correct
7 Correct 2 ms 2332 KB Output is correct
8 Correct 2 ms 2340 KB Output is correct
9 Correct 2 ms 2340 KB Output is correct
10 Correct 2 ms 2324 KB Output is correct
11 Correct 4 ms 2656 KB Output is correct
12 Correct 2 ms 2324 KB Output is correct
13 Correct 2 ms 2336 KB Output is correct
14 Correct 2 ms 2332 KB Output is correct
15 Correct 2 ms 2736 KB Output is correct
16 Correct 2 ms 2340 KB Output is correct
17 Correct 2 ms 2336 KB Output is correct
18 Correct 2 ms 2340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 18 ms 6428 KB Output is correct
2 Correct 22 ms 6432 KB Output is correct
3 Correct 19 ms 6868 KB Output is correct
4 Correct 12 ms 4412 KB Output is correct
5 Correct 12 ms 5436 KB Output is correct
6 Correct 12 ms 4920 KB Output is correct
7 Correct 11 ms 5184 KB Output is correct
8 Correct 12 ms 5172 KB Output is correct
9 Correct 11 ms 5176 KB Output is correct
10 Correct 9 ms 4416 KB Output is correct
11 Correct 9 ms 4424 KB Output is correct
12 Correct 10 ms 4396 KB Output is correct
13 Correct 11 ms 4384 KB Output is correct
14 Correct 10 ms 4396 KB Output is correct
15 Correct 13 ms 4924 KB Output is correct
16 Correct 11 ms 4784 KB Output is correct
17 Correct 11 ms 4404 KB Output is correct
18 Correct 11 ms 4584 KB Output is correct
19 Correct 11 ms 4408 KB Output is correct
20 Correct 9 ms 5440 KB Output is correct
21 Correct 10 ms 5176 KB Output is correct
22 Correct 13 ms 4916 KB Output is correct
23 Correct 13 ms 4928 KB Output is correct
24 Correct 12 ms 4928 KB Output is correct
25 Correct 11 ms 4928 KB Output is correct
26 Correct 11 ms 4928 KB Output is correct
27 Correct 11 ms 4920 KB Output is correct
28 Correct 11 ms 5256 KB Output is correct
29 Correct 11 ms 4720 KB Output is correct
30 Correct 11 ms 4916 KB Output is correct
31 Correct 2 ms 2336 KB Output is correct
32 Correct 2 ms 2324 KB Output is correct
33 Correct 2 ms 2332 KB Output is correct
34 Correct 2 ms 2836 KB Output is correct
35 Correct 2 ms 2320 KB Output is correct
36 Correct 2 ms 2588 KB Output is correct
37 Correct 2 ms 2324 KB Output is correct
38 Correct 2 ms 2340 KB Output is correct
39 Correct 2 ms 2328 KB Output is correct
40 Correct 2 ms 2780 KB Output is correct
41 Correct 2 ms 2328 KB Output is correct
42 Correct 2 ms 2324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2428 KB Output is correct
2 Correct 2 ms 2336 KB Output is correct
3 Correct 2 ms 2336 KB Output is correct
4 Correct 3 ms 2884 KB Output is correct
5 Correct 3 ms 2880 KB Output is correct
6 Correct 3 ms 2888 KB Output is correct
7 Correct 3 ms 2880 KB Output is correct
8 Correct 3 ms 2876 KB Output is correct
9 Correct 11 ms 6460 KB Output is correct
10 Correct 11 ms 6420 KB Output is correct
11 Correct 9 ms 6456 KB Output is correct
12 Correct 2 ms 2324 KB Output is correct
13 Correct 2 ms 2320 KB Output is correct
14 Correct 2 ms 2324 KB Output is correct
15 Correct 2 ms 2336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 18 ms 6432 KB Output is correct
2 Correct 18 ms 6440 KB Output is correct
3 Correct 18 ms 6492 KB Output is correct
4 Correct 11 ms 4408 KB Output is correct
5 Correct 12 ms 5952 KB Output is correct
6 Correct 13 ms 5428 KB Output is correct
7 Correct 14 ms 5176 KB Output is correct
8 Correct 11 ms 4924 KB Output is correct
9 Correct 11 ms 4928 KB Output is correct
10 Correct 9 ms 4416 KB Output is correct
11 Correct 10 ms 4416 KB Output is correct
12 Correct 9 ms 4392 KB Output is correct
13 Correct 10 ms 4384 KB Output is correct
14 Correct 12 ms 4556 KB Output is correct
15 Correct 11 ms 4928 KB Output is correct
16 Correct 11 ms 4920 KB Output is correct
17 Correct 11 ms 4412 KB Output is correct
18 Correct 11 ms 4480 KB Output is correct
19 Correct 11 ms 4416 KB Output is correct
20 Correct 9 ms 5436 KB Output is correct
21 Correct 9 ms 5188 KB Output is correct
22 Correct 11 ms 4920 KB Output is correct
23 Correct 11 ms 4928 KB Output is correct
24 Correct 11 ms 4920 KB Output is correct
25 Correct 12 ms 5360 KB Output is correct
26 Correct 11 ms 4920 KB Output is correct
27 Correct 11 ms 5188 KB Output is correct
28 Correct 11 ms 4928 KB Output is correct
29 Correct 10 ms 4904 KB Output is correct
30 Correct 11 ms 4904 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 6432 KB Output is correct
2 Correct 19 ms 6392 KB Output is correct
3 Correct 18 ms 6436 KB Output is correct
4 Correct 11 ms 4420 KB Output is correct
5 Correct 12 ms 5948 KB Output is correct
6 Correct 11 ms 4936 KB Output is correct
7 Correct 11 ms 4932 KB Output is correct
8 Correct 11 ms 5180 KB Output is correct
9 Correct 11 ms 4916 KB Output is correct
10 Correct 9 ms 4412 KB Output is correct
11 Correct 9 ms 4412 KB Output is correct
12 Correct 9 ms 4396 KB Output is correct
13 Correct 10 ms 4388 KB Output is correct
14 Correct 11 ms 4396 KB Output is correct
15 Correct 11 ms 4920 KB Output is correct
16 Correct 11 ms 5184 KB Output is correct
17 Correct 11 ms 4408 KB Output is correct
18 Correct 11 ms 4408 KB Output is correct
19 Correct 11 ms 4400 KB Output is correct
20 Correct 9 ms 5392 KB Output is correct
21 Correct 10 ms 5172 KB Output is correct
22 Correct 11 ms 5000 KB Output is correct
23 Correct 11 ms 4932 KB Output is correct
24 Correct 11 ms 4916 KB Output is correct
25 Correct 11 ms 4928 KB Output is correct
26 Correct 11 ms 4920 KB Output is correct
27 Correct 11 ms 5432 KB Output is correct
28 Correct 11 ms 5432 KB Output is correct
29 Correct 11 ms 4968 KB Output is correct
30 Correct 11 ms 4904 KB Output is correct
31 Correct 2 ms 2336 KB Output is correct
32 Correct 2 ms 2316 KB Output is correct
33 Correct 2 ms 2340 KB Output is correct
34 Correct 2 ms 2332 KB Output is correct
35 Correct 2 ms 2832 KB Output is correct
36 Correct 2 ms 2336 KB Output is correct
37 Correct 2 ms 2324 KB Output is correct
38 Correct 2 ms 2340 KB Output is correct
39 Correct 2 ms 2336 KB Output is correct
40 Correct 2 ms 2320 KB Output is correct
41 Correct 2 ms 2320 KB Output is correct
42 Correct 2 ms 2580 KB Output is correct