Submission #122749

# Submission time Handle Problem Language Result Execution time Memory
122749 2019-06-29T08:31:40 Z 송준혁(#3002) Amusement Park (JOI17_amusement_park) C++14
10 / 100
86 ms 3780 KB
#include <bits/stdc++.h>
#include "Joi.h"
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;

static int N, M;
static vector<int> adj[10101];
static int C[10101], num;
static queue<int> Q;

static void dfs(int u){
    if (C[u] != -1) return;
    if (num >= 60) return;
    C[u] = num++;
    for (int v : adj[u]) dfs(v);
}

static LL Col(int u, LL chk){
    if (C[u] == -1) return chk;
    if (chk & (1ll<<C[u])) return chk;
    chk |= (1ll<<C[u]);
    if (__builtin_popcountl(chk) == 59) return chk;
    for (int v : adj[u]) chk = Col(v, chk);
    return chk;
}

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++) {
        adj[A[i]].push_back(B[i]);
        adj[B[i]].push_back(A[i]);
    }
    memset(C, -1, sizeof C);
    dfs(0);
    for (int i=0; i<N; i++){
        if (C[i] == -1) continue;
        for (int j : adj[i]) Q.push(j);
    }
    while (!Q.empty()){
        int u = Q.front();
        Q.pop();
        if (C[u] != -1) continue;
        LL chk = 0;
        for (int v : adj[u]) chk = Col(v, chk);
        for (int i=0; i<60; i++) if (~chk & (1ll<<i)) C[u] = i;
        for (int v : adj[u]) Q.push(v);
    }
    for (int i=0; i<N; i++) MessageBoard(i, (X & (1ll << C[i])) ? 1 : 0);
}
#include <bits/stdc++.h>
#include "Ioi.h"
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;

static int N, M;
static vector<int> adj[10101];
static int C[10101], num;
static LL ans;
static queue<int> Q;

static void dfs(int u){
    if (C[u] != -1) return;
    if (num >= 60) return;
    C[u] = num++;
    for (int v : adj[u]) dfs(v);
}

static LL Col(int u, LL chk){
    if (C[u] == -1) return chk;
    if (chk & (1ll<<C[u])) return chk;
    chk |= (1ll<<C[u]);
    if (__builtin_popcountl(chk) == 59) return chk;
    for (int v : adj[u]) chk = Col(v, chk);
    return chk;
}

static LL Findans(int u, int p, LL chk){
    if (C[u] == -1) return chk;
    if (chk & (1ll<<C[u])) return chk;
    chk |= 1ll<<C[u];
    ans |= (LL)Move(u)<<C[u];
    if (__builtin_popcountl(chk) == 60) {
        Move(p);
        return chk;
    }
    for (int v : adj[u]) chk = Findans(v, u, chk);
    Move(p);
    return chk;
}

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++) {
        adj[A[i]].push_back(B[i]);
        adj[B[i]].push_back(A[i]);
    }
    memset(C, -1, sizeof C);
    dfs(0);
    for (int i=0; i<N; i++){
        if (C[i] == -1) continue;
        for (int j : adj[i]) Q.push(j);
    }
    while (!Q.empty()){
        int u = Q.front();
        Q.pop();
        if (C[u] != -1) continue;
        LL chk = 0;
        for (int v : adj[u]) chk = Col(v, chk);
        for (int i=0; i<60; i++) if (~chk & (1ll<<i)) C[u] = i;
        for (int v : adj[u]) Q.push(v);
    }

    LL chk = 1ll<<C[P];
    ans |= (LL)V<<C[P];
    for (int v : adj[P]) {
        chk = Findans(v, P, chk);
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1460 KB Output is correct
2 Correct 4 ms 1456 KB Output is correct
3 Incorrect 4 ms 1468 KB Wrong Answer [7]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 77 ms 3704 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1264 KB Output is correct
2 Correct 4 ms 1400 KB Output is correct
3 Correct 4 ms 1272 KB Output is correct
4 Correct 8 ms 1636 KB Output is correct
5 Correct 8 ms 1636 KB Output is correct
6 Correct 8 ms 1560 KB Output is correct
7 Correct 8 ms 1636 KB Output is correct
8 Correct 8 ms 1644 KB Output is correct
9 Correct 31 ms 2880 KB Output is correct
10 Correct 31 ms 2620 KB Output is correct
11 Correct 31 ms 2680 KB Output is correct
12 Correct 4 ms 1264 KB Output is correct
13 Correct 4 ms 1452 KB Output is correct
14 Correct 4 ms 1488 KB Output is correct
15 Correct 4 ms 1548 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 86 ms 3780 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 73 ms 3608 KB Wrong Answer [7]
2 Halted 0 ms 0 KB -