Submission #26887

# Submission time Handle Problem Language Result Execution time Memory
26887 2017-07-07T02:41:17 Z wangyenjen City (JOI17_city) C++14
0 / 100
167 ms 19440 KB
/// Author: Wang, Yen-Jen
#include "Encoder.h"
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

static const int MAX_N = 250000 + 7;

static int dp[MAX_N];
static ll dp2[MAX_N];
static vector<int> G[MAX_N];

static void dfs(int u , int fa) {
    if(fa == -1) {
        dp[u] = 0;
        dp2[u] = 0;
    }
    dp2[u] |= (1ll<<dp[u]);
    dp[u]++;
    assert(dp[u] <= 61);
    int cc = 0;
    int cnt = (int)G[u].size();
    if(~fa) cnt--;
    while((1<<cc) < cnt) cc++;
    for(int v : G[u]) {
        if(v == fa) continue;
        dp[v] = dp[u] + cc + 1;
        dp2[v] = ((ll)cnt<<dp[u]) | dp2[u];
        cnt--;
        dfs(v , u);
    }
}

void Encode(int N , int A[] , int B[]) {
    for(int i = 0; i < N; i++) G[i].clear();
    for(int i = 0; i < N - 1; i++) {
        G[A[i]].push_back(B[i]);
        G[B[i]].push_back(A[i]);
    }
    dfs(0 , -1);
    for(int i = 0; i < N; i++) Code(i , dp2[i]);
}
/// Author: Wang, Yen-Jen
#include "Device.h"
#include <bits/stdc++.h>

using namespace std;

void InitDevice() {
}

int Answer(long long S , long long T) {
    if((S&T) == T && (S|T) == S) return 0;
    else if((S&T) == S && (S|T) == T) return 1;
	else return 2;
}
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 12488 KB Wrong Answer [6]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 167 ms 19440 KB Wrong Answer [6]
2 Halted 0 ms 0 KB -