Submission #590556

# Submission time Handle Problem Language Result Execution time Memory
590556 2022-07-06T06:35:20 Z 이동현(#8415) Amusement Park (JOI17_amusement_park) C++14
100 / 100
59 ms 4568 KB
#include "Joi.h"
#include <bits/stdc++.h>
using namespace std;

const static int NS = (int)1e4 + 4;
static int n, m;
static vector<int> way[NS];
static vector<int> way2[NS];
static int col[NS], pr[NS], chk[64], cnt;

static vector<int> getorder(){
    vector<int> que(n);
    vector<int> qchk(n);
    int f = 0, r = 0;
    qchk[0] = 1; que[r++] = 0;
    while(f < r){
        for(auto&nxt:way[que[f]]){
            if(qchk[nxt]){
                continue;
            }
            qchk[nxt] = 1;
            pr[nxt] = que[f];
            que[r++] = nxt;
        }
        ++f;
    }
    return que;
}

static void dfs(int x){
    chk[col[x]] = 1; ++cnt;
    if(cnt >= 59) return;
    for(auto&nxt:way2[x]){
        if(chk[col[nxt]]){
            continue;
        }
        dfs(nxt);
        if(cnt >= 59) return;
    }
}

void Joi(int N, int M, int A[], int B[], long long X, int T) {
    n = N;
    m = M;
    for(int i = 0; i < m; ++i){
        way[A[i]].push_back(B[i]);
        way[B[i]].push_back(A[i]);
    }
    memset(col, -1, sizeof(col));
    vector<int> vc = getorder();
    for(int i = 0; i < 60; ++i){
        col[vc[i]] = i;
        if(i){
            way2[vc[i]].push_back(pr[vc[i]]);
            way2[pr[vc[i]]].push_back(vc[i]);
        }
    }
    for(int i = 60; i < (int)vc.size(); ++i){
        memset(chk, 0, sizeof(chk));
        cnt = 0;
        dfs(pr[vc[i]]);
        for(int j = 0; j < 60; ++j){
            if(!chk[j]){
                col[vc[i]] = j;
                break;
            }
        }
        way2[vc[i]].push_back(pr[vc[i]]);
        way2[pr[vc[i]]].push_back(vc[i]);
    }
    for(int i = 0; i < n; ++i){
        MessageBoard(i, !!(X & (1ll << col[i])));
    }
}
#include "Ioi.h"
#include <bits/stdc++.h>
using namespace std;

static const int NS = (int)1e4 + 4;
static int n, m;
static vector<int> way[NS];
static vector<int> way2[NS];
static int col[NS], pr[NS], chk[64], cnt;
static long long ans;

static vector<int> getorder(){
    vector<int> que(n);
    vector<int> qchk(n);
    int f = 0, r = 0;
    qchk[0] = 1; que[r++] = 0;
    while(f < r){
        for(auto&nxt:way[que[f]]){
            if(qchk[nxt]){
                continue;
            }
            qchk[nxt] = 1;
            pr[nxt] = que[f];
            que[r++] = nxt;
        }
        ++f;
    }
    return que;
}

static void dfs(int x){
    chk[col[x]] = 1; ++cnt;
    if(cnt >= 59) return;
    for(auto&nxt:way2[x]){
        if(chk[col[nxt]]){
            continue;
        }
        dfs(nxt);
        if(cnt >= 59) return;
    }
}

static void dfs2(int x){
    for(auto&nxt:way[x]){
        if(chk[col[nxt]]){
            continue;
        }
        chk[col[nxt]] = 1;
        ans += (((long long)Move(nxt)) << col[nxt]);
        dfs2(nxt);
        Move(x);
    }
}

long long Ioi(int N, int M, int A[], int B[], int P, int V, int T) {
    n = N;
    m = M;
    for(int i = 0; i < m; ++i){
        way[A[i]].push_back(B[i]);
        way[B[i]].push_back(A[i]);
    }
    memset(col, -1, sizeof(col));
    vector<int> vc = getorder();
    for(int i = 0; i < 60; ++i){
        col[vc[i]] = i;
        if(i){
            way2[vc[i]].push_back(pr[vc[i]]);
            way2[pr[vc[i]]].push_back(vc[i]);
        }
    }
    for(int i = 60; i < (int)vc.size(); ++i){
        memset(chk, 0, sizeof(chk));
        cnt = 0;
        dfs(pr[vc[i]]);
        for(int j = 0; j < 60; ++j){
            if(!chk[j]){
                col[vc[i]] = j;
                break;
            }
        }
        way2[vc[i]].push_back(pr[vc[i]]);
        way2[pr[vc[i]]].push_back(vc[i]);
    }
    memset(chk, 0, sizeof(chk));
    chk[col[P]] = 1;
    ans += V * (1ll << col[P]);
    dfs2(P);
    return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1536 KB Output is correct
2 Correct 2 ms 1544 KB Output is correct
3 Correct 2 ms 1668 KB Output is correct
4 Correct 2 ms 1536 KB Output is correct
5 Correct 2 ms 1544 KB Output is correct
6 Correct 2 ms 1628 KB Output is correct
7 Correct 2 ms 1796 KB Output is correct
8 Correct 2 ms 1804 KB Output is correct
9 Correct 2 ms 1796 KB Output is correct
10 Correct 2 ms 1544 KB Output is correct
11 Correct 4 ms 1972 KB Output is correct
12 Correct 0 ms 1544 KB Output is correct
13 Correct 2 ms 1668 KB Output is correct
14 Correct 2 ms 1680 KB Output is correct
15 Correct 2 ms 1808 KB Output is correct
16 Correct 2 ms 1800 KB Output is correct
17 Correct 2 ms 1804 KB Output is correct
18 Correct 2 ms 1668 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 46 ms 4492 KB Output is correct
2 Correct 40 ms 4540 KB Output is correct
3 Correct 37 ms 4560 KB Output is correct
4 Correct 25 ms 3684 KB Output is correct
5 Correct 26 ms 4008 KB Output is correct
6 Correct 28 ms 3788 KB Output is correct
7 Correct 30 ms 3864 KB Output is correct
8 Correct 28 ms 3668 KB Output is correct
9 Correct 30 ms 3852 KB Output is correct
10 Correct 24 ms 3996 KB Output is correct
11 Correct 22 ms 4044 KB Output is correct
12 Correct 26 ms 3576 KB Output is correct
13 Correct 23 ms 3616 KB Output is correct
14 Correct 24 ms 3712 KB Output is correct
15 Correct 32 ms 3808 KB Output is correct
16 Correct 38 ms 3760 KB Output is correct
17 Correct 24 ms 3780 KB Output is correct
18 Correct 27 ms 3788 KB Output is correct
19 Correct 27 ms 3808 KB Output is correct
20 Correct 24 ms 3788 KB Output is correct
21 Correct 24 ms 3792 KB Output is correct
22 Correct 25 ms 3752 KB Output is correct
23 Correct 29 ms 3764 KB Output is correct
24 Correct 25 ms 3796 KB Output is correct
25 Correct 27 ms 3784 KB Output is correct
26 Correct 31 ms 3832 KB Output is correct
27 Correct 35 ms 3760 KB Output is correct
28 Correct 34 ms 3836 KB Output is correct
29 Correct 27 ms 3632 KB Output is correct
30 Correct 28 ms 3652 KB Output is correct
31 Correct 2 ms 1548 KB Output is correct
32 Correct 2 ms 1544 KB Output is correct
33 Correct 2 ms 1796 KB Output is correct
34 Correct 2 ms 1536 KB Output is correct
35 Correct 1 ms 1536 KB Output is correct
36 Correct 1 ms 1540 KB Output is correct
37 Correct 2 ms 1548 KB Output is correct
38 Correct 2 ms 1536 KB Output is correct
39 Correct 2 ms 1536 KB Output is correct
40 Correct 2 ms 1536 KB Output is correct
41 Correct 2 ms 1536 KB Output is correct
42 Correct 2 ms 1536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1536 KB Output is correct
2 Correct 2 ms 1544 KB Output is correct
3 Correct 2 ms 1544 KB Output is correct
4 Correct 4 ms 1952 KB Output is correct
5 Correct 4 ms 1956 KB Output is correct
6 Correct 5 ms 1948 KB Output is correct
7 Correct 5 ms 1956 KB Output is correct
8 Correct 5 ms 1956 KB Output is correct
9 Correct 22 ms 3748 KB Output is correct
10 Correct 22 ms 3744 KB Output is correct
11 Correct 26 ms 3788 KB Output is correct
12 Correct 2 ms 1544 KB Output is correct
13 Correct 1 ms 1544 KB Output is correct
14 Correct 1 ms 1536 KB Output is correct
15 Correct 1 ms 1536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 41 ms 4480 KB Output is correct
2 Correct 38 ms 4460 KB Output is correct
3 Correct 46 ms 4568 KB Output is correct
4 Correct 26 ms 3740 KB Output is correct
5 Correct 34 ms 3804 KB Output is correct
6 Correct 26 ms 3756 KB Output is correct
7 Correct 24 ms 3788 KB Output is correct
8 Correct 25 ms 3804 KB Output is correct
9 Correct 25 ms 3792 KB Output is correct
10 Correct 24 ms 3900 KB Output is correct
11 Correct 27 ms 4040 KB Output is correct
12 Correct 28 ms 3448 KB Output is correct
13 Correct 27 ms 3644 KB Output is correct
14 Correct 23 ms 3704 KB Output is correct
15 Correct 25 ms 3776 KB Output is correct
16 Correct 25 ms 3828 KB Output is correct
17 Correct 25 ms 3784 KB Output is correct
18 Correct 26 ms 3752 KB Output is correct
19 Correct 24 ms 3736 KB Output is correct
20 Correct 24 ms 3792 KB Output is correct
21 Correct 22 ms 3780 KB Output is correct
22 Correct 30 ms 3732 KB Output is correct
23 Correct 27 ms 3744 KB Output is correct
24 Correct 27 ms 3720 KB Output is correct
25 Correct 27 ms 3704 KB Output is correct
26 Correct 24 ms 3816 KB Output is correct
27 Correct 25 ms 3720 KB Output is correct
28 Correct 25 ms 3700 KB Output is correct
29 Correct 23 ms 3620 KB Output is correct
30 Correct 27 ms 3636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 59 ms 4492 KB Output is correct
2 Correct 51 ms 4380 KB Output is correct
3 Correct 38 ms 4412 KB Output is correct
4 Correct 24 ms 3816 KB Output is correct
5 Correct 25 ms 3788 KB Output is correct
6 Correct 27 ms 3812 KB Output is correct
7 Correct 27 ms 3864 KB Output is correct
8 Correct 27 ms 3792 KB Output is correct
9 Correct 27 ms 3864 KB Output is correct
10 Correct 26 ms 3908 KB Output is correct
11 Correct 29 ms 4124 KB Output is correct
12 Correct 23 ms 3728 KB Output is correct
13 Correct 22 ms 3840 KB Output is correct
14 Correct 24 ms 3864 KB Output is correct
15 Correct 26 ms 3900 KB Output is correct
16 Correct 28 ms 4016 KB Output is correct
17 Correct 33 ms 4036 KB Output is correct
18 Correct 25 ms 4092 KB Output is correct
19 Correct 31 ms 3960 KB Output is correct
20 Correct 27 ms 4064 KB Output is correct
21 Correct 30 ms 3876 KB Output is correct
22 Correct 26 ms 3992 KB Output is correct
23 Correct 25 ms 4104 KB Output is correct
24 Correct 26 ms 3992 KB Output is correct
25 Correct 28 ms 3912 KB Output is correct
26 Correct 26 ms 3992 KB Output is correct
27 Correct 30 ms 3936 KB Output is correct
28 Correct 26 ms 3848 KB Output is correct
29 Correct 30 ms 3820 KB Output is correct
30 Correct 24 ms 3864 KB Output is correct
31 Correct 2 ms 1676 KB Output is correct
32 Correct 1 ms 1668 KB Output is correct
33 Correct 2 ms 1808 KB Output is correct
34 Correct 2 ms 1536 KB Output is correct
35 Correct 2 ms 1552 KB Output is correct
36 Correct 1 ms 1548 KB Output is correct
37 Correct 2 ms 1540 KB Output is correct
38 Correct 2 ms 1540 KB Output is correct
39 Correct 2 ms 1660 KB Output is correct
40 Correct 2 ms 1540 KB Output is correct
41 Correct 2 ms 1580 KB Output is correct
42 Correct 2 ms 1548 KB Output is correct