Submission #1080513

#TimeUsernameProblemLanguageResultExecution timeMemory
1080513veehjCity (JOI17_city)C++17
8 / 100
204 ms16120 KiB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define F first
#define S second
#define pb push_back
#define sz(a) (ll) a.size()
#define all(x) (x).begin(), (x).end()
#include "Encoder.h"
vector<vector<ll>> adj;
vector<bool> vist;
set<ll> s;

void go(int nw){
    vist[nw]=1;
    ll c=nw;
    for(auto& u : s){
        c*=10;
        c+=u;
    }
    s.insert(nw);
    Code(nw, c);
    for(auto& u : adj[nw]){
        if(vist[u]) continue;
        go(u);
    }
    s.erase(nw);
}

void Encode(int N, int A[], int B[]){
    adj.assign(N, vector<ll>(0));
    vist.assign(N, 0);
    for(int i=0; i<N-1; i++){
        adj[A[i]].pb(B[i]);
        adj[B[i]].pb(A[i]);
    }
    go(0);
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define F first
#define S second
#define pb push_back
#define sz(a) (ll) a.size()
#define all(x) (x).begin(), (x).end()
#include "Device.h"

void InitDevice(){
}

int Answer(long long s, long long t){
    if(s==0) return 1;
    if(t==0) return 0;
    set<int> a={}, b={};
    int A, B;
    while(s){
        if(s<10){
            A=s;
            break;
        }
        a.insert(s%10);
        s/=10;
    }
    while(t){
        if(t<10){
            B=t;
            break;
        }
        b.insert(t%10);
        t/=10;
    }
    if(a.count(B)) return 0;
    if(b.count(A)) return 1;
    return 2;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...