답안 #100753

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
100753 2019-03-14T07:21:10 Z dlalswp25 Amusement Park (JOI17_amusement_park) C++14
100 / 100
67 ms 9500 KB
#include "Joi.h"
#include <bits/stdc++.h>

using namespace std;

vector<int> G[10101];
vector<int> adj[10101];
bool vst[10101];

int C[10101];
int W[10101];
int cid;
vector<int> tre[10101];
int cnt;

void init(int x) {
    vst[x] = true;
    for(int i : G[x]) {
        if(vst[i]) continue;
        adj[x].push_back(i);
        adj[i].push_back(x);
        init(i);
    }
}

void dfs(int x, int p) {
    cnt++;
    tre[cid].push_back(x);
    C[x] = cid;
    for(int i : adj[x]) {
        if(cnt >= 60) break;
        if(i == p) continue;
        dfs(i, x);
    }
}

void dfs2(int x, int p, int c) {
    tre[cid].push_back(x);
    cnt++;
    for(int i : adj[x]) {
        if(cnt >= 60) break;
        if(C[i] != c) continue;
        if(i == p) continue;
        dfs2(i, x, c);
    }
}

void mk(int x, int p) {
    cid++;
    cnt = 0;
    dfs(x, p);
    if(tre[cid].size() < 60) {
        dfs2(p, -1, C[p]);
    }
}

void sol(int x, int p) {
    if(!C[x]) mk(x, p);
    for(int i : adj[x]) {
        if(i != p) sol(i, x);
    }
}

bool used[66];

void Joi(int N, int M, int A[], int B[], long long X, int T) {
    for(int i = 0; i < N; i++) W[i] = 60;
    for(int i = 0; i < M; i++) {
        G[A[i]].push_back(B[i]);
        G[B[i]].push_back(A[i]);
    }
    init(0);
    sol(0, -1);
    
    for(int i = 1; i <= cid; i++) {
        for(int j = 0; j < 60; j++) used[j] = false;
        for(int j : tre[i]) used[W[j]] = true;
        int p = 0;
        for(int j : tre[i]) {
            if(W[j] < 60) continue;
            while(used[p]) p++;
            W[j] = p;
            used[p] = true;
        }
    }
    for(int i = 0; i < N; i++) MessageBoard(i, (X & ((1ll) << W[i])) > 0);
}
#include "Ioi.h"
#include <bits/stdc++.h>

using namespace std;

struct XX {

vector<int> G[10101];
vector<int> adj[10101];
bool vst[10101];

int C[10101];
int W[10101];
int cid;
vector<int> tre[10101];
int cnt;

void init(int x) {
    vst[x] = true;
    for(int i : G[x]) {
        if(vst[i]) continue;
        adj[x].push_back(i);
        adj[i].push_back(x);
        init(i);
    }
}

void dfs(int x, int p) {
    cnt++;
    tre[cid].push_back(x);
    C[x] = cid;
    for(int i : adj[x]) {
        if(cnt >= 60) break;
        if(i == p) continue;
        dfs(i, x);
    }
}

void dfs2(int x, int p, int c) {
    tre[cid].push_back(x);
    cnt++;
    for(int i : adj[x]) {
        if(cnt >= 60) break;
        if(C[i] != c) continue;
        if(i == p) continue;
        dfs2(i, x, c);
    }
}

void mk(int x, int p) {
    cid++;
    cnt = 0;
    dfs(x, p);
    if(tre[cid].size() < 60) {
        dfs2(p, -1, C[p]);
    }
}

void sol(int x, int p) {
    if(!C[x]) mk(x, p);
    for(int i : adj[x]) {
        if(i != p) sol(i, x);
    }
}

bool used[66];

}XXX;

int ans[66];
int c;

void trav(int x, int p) {
    for(int i : XXX.adj[x]) {
        if(i == p) continue;
        bool ok = false;
        for(int j : XXX.tre[c]) if(j == i) ok = true;
        if(!ok) continue;
        ans[XXX.W[i]] = Move(i);
        trav(i, x);
    }
    if(p != -1) Move(p);
}

long long Ioi(int N, int M, int A[], int B[], int P, int V, int T) {
    for(int i = 0; i < N; i++) XXX.W[i] = 60;
    for(int i = 0; i < M; i++) {
        XXX.G[A[i]].push_back(B[i]);
        XXX.G[B[i]].push_back(A[i]);
    }
    XXX.cid = 0;
    XXX.init(0);
    XXX.sol(0, -1);
    
    for(int i = 1; i <= XXX.cid; i++) {
        for(int j = 0; j < 60; j++) XXX.used[j] = false;
        for(int j : XXX.tre[i]) XXX.used[XXX.W[j]] = true;
        int p = 0;
        for(int j : XXX.tre[i]) {
            if(XXX.W[j] < 60) continue;
            while(XXX.used[p]) p++;
            XXX.W[j] = p;
            XXX.used[p] = true;
        }
    }
    
    ans[XXX.W[P]] = V;
    c = XXX.C[P];
    trav(P, -1);
           
    long long ret = 0;
    for(int i = 0; i < 60; i++) if(ans[i]) ret += ((1ll) << i);
    
    return ret;
}

Compilation message

Ioi.cpp: In function 'long long int Ioi(int, int, int*, int*, int, int, int)':
Ioi.cpp:55:13: warning: array subscript is below array bounds [-Warray-bounds]
         dfs2(p, -1, C[p]);
         ~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 2312 KB Output is correct
2 Correct 6 ms 2304 KB Output is correct
3 Correct 6 ms 2444 KB Output is correct
4 Correct 4 ms 2176 KB Output is correct
5 Correct 5 ms 2204 KB Output is correct
6 Correct 6 ms 2420 KB Output is correct
7 Correct 6 ms 2408 KB Output is correct
8 Correct 6 ms 2472 KB Output is correct
9 Correct 5 ms 2316 KB Output is correct
10 Correct 7 ms 2440 KB Output is correct
11 Correct 11 ms 2628 KB Output is correct
12 Correct 6 ms 2204 KB Output is correct
13 Correct 6 ms 2416 KB Output is correct
14 Correct 6 ms 2308 KB Output is correct
15 Correct 7 ms 2436 KB Output is correct
16 Correct 7 ms 2180 KB Output is correct
17 Correct 6 ms 2308 KB Output is correct
18 Correct 6 ms 2308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 43 ms 7292 KB Output is correct
2 Correct 41 ms 7548 KB Output is correct
3 Correct 40 ms 7536 KB Output is correct
4 Correct 31 ms 4880 KB Output is correct
5 Correct 27 ms 6040 KB Output is correct
6 Correct 33 ms 6160 KB Output is correct
7 Correct 46 ms 6040 KB Output is correct
8 Correct 27 ms 6032 KB Output is correct
9 Correct 27 ms 6160 KB Output is correct
10 Correct 57 ms 9484 KB Output is correct
11 Correct 41 ms 9492 KB Output is correct
12 Correct 22 ms 4472 KB Output is correct
13 Correct 29 ms 4472 KB Output is correct
14 Correct 28 ms 4620 KB Output is correct
15 Correct 29 ms 5008 KB Output is correct
16 Correct 30 ms 5116 KB Output is correct
17 Correct 39 ms 4880 KB Output is correct
18 Correct 27 ms 4876 KB Output is correct
19 Correct 26 ms 4888 KB Output is correct
20 Correct 23 ms 5768 KB Output is correct
21 Correct 18 ms 5776 KB Output is correct
22 Correct 33 ms 6460 KB Output is correct
23 Correct 39 ms 6880 KB Output is correct
24 Correct 40 ms 6644 KB Output is correct
25 Correct 47 ms 6796 KB Output is correct
26 Correct 36 ms 6920 KB Output is correct
27 Correct 36 ms 6808 KB Output is correct
28 Correct 36 ms 6928 KB Output is correct
29 Correct 38 ms 6264 KB Output is correct
30 Correct 35 ms 6640 KB Output is correct
31 Correct 5 ms 2176 KB Output is correct
32 Correct 6 ms 2176 KB Output is correct
33 Correct 7 ms 2436 KB Output is correct
34 Correct 6 ms 2176 KB Output is correct
35 Correct 5 ms 2176 KB Output is correct
36 Correct 6 ms 2312 KB Output is correct
37 Correct 6 ms 2176 KB Output is correct
38 Correct 5 ms 2176 KB Output is correct
39 Correct 6 ms 2176 KB Output is correct
40 Correct 5 ms 2176 KB Output is correct
41 Correct 5 ms 2216 KB Output is correct
42 Correct 6 ms 2312 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 2176 KB Output is correct
2 Correct 6 ms 2312 KB Output is correct
3 Correct 6 ms 2176 KB Output is correct
4 Correct 8 ms 3212 KB Output is correct
5 Correct 9 ms 3084 KB Output is correct
6 Correct 8 ms 3080 KB Output is correct
7 Correct 8 ms 3108 KB Output is correct
8 Correct 8 ms 2844 KB Output is correct
9 Correct 20 ms 6912 KB Output is correct
10 Correct 22 ms 6916 KB Output is correct
11 Correct 20 ms 6808 KB Output is correct
12 Correct 6 ms 2432 KB Output is correct
13 Correct 6 ms 2304 KB Output is correct
14 Correct 7 ms 2440 KB Output is correct
15 Correct 6 ms 2280 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 50 ms 7680 KB Output is correct
2 Correct 45 ms 7428 KB Output is correct
3 Correct 46 ms 7564 KB Output is correct
4 Correct 26 ms 5008 KB Output is correct
5 Correct 28 ms 6544 KB Output is correct
6 Correct 28 ms 6416 KB Output is correct
7 Correct 30 ms 6160 KB Output is correct
8 Correct 36 ms 5892 KB Output is correct
9 Correct 33 ms 5984 KB Output is correct
10 Correct 46 ms 9500 KB Output is correct
11 Correct 67 ms 9480 KB Output is correct
12 Correct 26 ms 4472 KB Output is correct
13 Correct 28 ms 4472 KB Output is correct
14 Correct 22 ms 4836 KB Output is correct
15 Correct 25 ms 5008 KB Output is correct
16 Correct 26 ms 5016 KB Output is correct
17 Correct 30 ms 5036 KB Output is correct
18 Correct 30 ms 5016 KB Output is correct
19 Correct 24 ms 5044 KB Output is correct
20 Correct 19 ms 5784 KB Output is correct
21 Correct 18 ms 5692 KB Output is correct
22 Correct 41 ms 6860 KB Output is correct
23 Correct 39 ms 6844 KB Output is correct
24 Correct 33 ms 6808 KB Output is correct
25 Correct 39 ms 6808 KB Output is correct
26 Correct 31 ms 6808 KB Output is correct
27 Correct 31 ms 7056 KB Output is correct
28 Correct 30 ms 6552 KB Output is correct
29 Correct 30 ms 6308 KB Output is correct
30 Correct 39 ms 6652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 7676 KB Output is correct
2 Correct 46 ms 7548 KB Output is correct
3 Correct 44 ms 7428 KB Output is correct
4 Correct 34 ms 5128 KB Output is correct
5 Correct 27 ms 6916 KB Output is correct
6 Correct 30 ms 5956 KB Output is correct
7 Correct 32 ms 5804 KB Output is correct
8 Correct 34 ms 6176 KB Output is correct
9 Correct 31 ms 6160 KB Output is correct
10 Correct 47 ms 9400 KB Output is correct
11 Correct 57 ms 9364 KB Output is correct
12 Correct 32 ms 4592 KB Output is correct
13 Correct 24 ms 4472 KB Output is correct
14 Correct 28 ms 4740 KB Output is correct
15 Correct 25 ms 5024 KB Output is correct
16 Correct 28 ms 5008 KB Output is correct
17 Correct 32 ms 5016 KB Output is correct
18 Correct 26 ms 5016 KB Output is correct
19 Correct 37 ms 5004 KB Output is correct
20 Correct 22 ms 5700 KB Output is correct
21 Correct 24 ms 5776 KB Output is correct
22 Correct 37 ms 6792 KB Output is correct
23 Correct 39 ms 6540 KB Output is correct
24 Correct 36 ms 6672 KB Output is correct
25 Correct 38 ms 6672 KB Output is correct
26 Correct 36 ms 6624 KB Output is correct
27 Correct 41 ms 6928 KB Output is correct
28 Correct 40 ms 7056 KB Output is correct
29 Correct 31 ms 6576 KB Output is correct
30 Correct 39 ms 6652 KB Output is correct
31 Correct 4 ms 2176 KB Output is correct
32 Correct 6 ms 2188 KB Output is correct
33 Correct 7 ms 2488 KB Output is correct
34 Correct 6 ms 2176 KB Output is correct
35 Correct 6 ms 2376 KB Output is correct
36 Correct 7 ms 2312 KB Output is correct
37 Correct 4 ms 2312 KB Output is correct
38 Correct 6 ms 2176 KB Output is correct
39 Correct 4 ms 2208 KB Output is correct
40 Correct 5 ms 2176 KB Output is correct
41 Correct 5 ms 2312 KB Output is correct
42 Correct 5 ms 2312 KB Output is correct