Submission #113631

#TimeUsernameProblemLanguageResultExecution timeMemory
113631popovicirobertCity (JOI17_city)C++14
22 / 100
523 ms57376 KiB
#include "Encoder.h"
#include <bits/stdc++.h>
#define ll long long

using namespace std;

static vector < vector <int> > g;
static vector <int> idl, idr;

void dfs(int nod, int par, int &sz) {
    idl[nod] = ++sz;
    for(auto it : g[nod]) {
        if(it != par) {
            dfs(it, nod, sz);
        }
    }
    idr[nod] = sz;
}

void Encode(int n, int A[], int B[]) {

    g.resize(n);
    int i;

    for(i = 0; i < n - 1; i++) {
        g[A[i]].push_back(B[i]);
        g[B[i]].push_back(A[i]);
    }

    idl.resize(n), idr.resize(n);
    int sz = 0;
    dfs(0, -1, sz);

    //vector <int> aux;

    /*for(i = 0; i < n; i++) {
        aux.push_back(idr[i] - idl[i]);
    }*/

    //sort(aux.begin(), aux.end());
    //aux.resize(unique(aux.begin(), aux.end()) - aux.begin());

    for(i = 0; i < n; i++) {
        ll a = idl[i], b = idr[i] - idl[i];

        Code(i, (b << 18) + a);
    }

}
#include "Device.h"
#include <bits/stdc++.h>
#define ll long long

using namespace std;

void InitDevice()
{
}

int Answer(long long S, long long T)
{

    ll ls = (S & ((1 << 18) - 1)), rs = ((S - ls) >> 18) + ls;
    ll lt = (T & ((1 << 18) - 1)), rt = ((T - lt) >> 18) + lt;

    if(ls <= lt && rt <= rs) {
        return 1;
    }

    if(lt <= ls && rs <= rt) {
        return 0;
    }

	return 2;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...