Submission #878812

# Submission time Handle Problem Language Result Execution time Memory
878812 2023-11-25T09:19:28 Z niter Unique Cities (JOI19_ho_t5) C++14
4 / 100
162 ms 11188 KB
#include <bits/stdc++.h>
#define pb push_back
#define ins isnert
#define pii pair<int,int>
#define ff first
#define ss second
#define loop(i,a,b) for(int i = (a); i < (b); i ++)
#define op(x) cerr << #x << " = " << x << endl;
#define opa(x) cerr << #x << " = " << x << ", ";
#define ops(x) cerr << x;
#define spac cerr << ' ';
#define entr cerr << endl;
#define STL(x) cerr << #x << " : "; for(auto &qwe:x) cerr << qwe << ' '; cerr << endl;
#define ARR(x, nnn) cerr << #x << " : "; loop(qwe,0,nnn) cerr << x[qwe] << ' '; cerr << endl;
#define BAE(x) (x).begin(), (x).end()
#define bye exit(0);
using namespace std;
mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count());

const int mxn = (int)(1e5) + 10;
vector<int> E[mxn];
int col[mxn];

vector<int> vec_col[mxn];
void dfs(int v, int par, int dis){
    vec_col[dis].pb(col[v]);
    for(auto &u:E[v]){
        if(u == par) continue;
        dfs(u, v, dis + 1);
    }
}
int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    int n, m; cin >> n >> m;
    loop(i,0,n-1){
        int a, b;
        cin >> a >> b;
        E[a].pb(b);
        E[b].pb(a);
    }
    vector<int> srt_col;
    loop(i,1,n+1){
        cin >> col[i];
        srt_col.pb(col[i]);
    }
    sort(BAE(srt_col));
    srt_col.resize(unique(BAE(srt_col)) - srt_col.begin());
    loop(i,1,n+1){
        col[i] = lower_bound(BAE(srt_col), col[i]) - srt_col.begin() + 1;
    }
    loop(i,1,n+1){
        loop(i,1,n+1) vec_col[i].clear();
        vector<int> vec_ans;
        dfs(i, -1, 0);
        loop(i,1,n+1){
            if(vec_col[i].size() == 1){
                vec_ans.pb(vec_col[i][0]);
            }
        }
        sort(BAE(vec_ans));
        vec_ans.resize(unique(BAE(vec_ans)) - vec_ans.begin());
        cout << vec_ans.size() << '\n';
    }
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 5468 KB Output is correct
2 Correct 30 ms 5688 KB Output is correct
3 Correct 31 ms 5468 KB Output is correct
4 Correct 46 ms 5816 KB Output is correct
5 Correct 35 ms 5468 KB Output is correct
6 Correct 117 ms 5796 KB Output is correct
7 Correct 51 ms 5788 KB Output is correct
8 Correct 31 ms 5468 KB Output is correct
9 Correct 40 ms 5872 KB Output is correct
10 Correct 39 ms 6056 KB Output is correct
11 Correct 37 ms 5728 KB Output is correct
12 Correct 26 ms 5724 KB Output is correct
13 Correct 95 ms 5724 KB Output is correct
14 Correct 46 ms 6572 KB Output is correct
15 Correct 47 ms 6444 KB Output is correct
16 Correct 27 ms 5468 KB Output is correct
17 Correct 61 ms 8440 KB Output is correct
18 Correct 58 ms 6712 KB Output is correct
19 Correct 37 ms 5684 KB Output is correct
20 Correct 162 ms 5812 KB Output is correct
21 Correct 56 ms 5724 KB Output is correct
22 Correct 36 ms 5468 KB Output is correct
23 Correct 40 ms 5724 KB Output is correct
24 Correct 47 ms 5736 KB Output is correct
25 Correct 37 ms 5724 KB Output is correct
26 Correct 36 ms 5724 KB Output is correct
27 Correct 107 ms 5792 KB Output is correct
28 Correct 81 ms 8084 KB Output is correct
29 Correct 48 ms 6492 KB Output is correct
30 Correct 23 ms 5468 KB Output is correct
31 Correct 86 ms 8276 KB Output is correct
32 Correct 53 ms 6684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 10844 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 11188 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 5468 KB Output is correct
2 Correct 30 ms 5688 KB Output is correct
3 Correct 31 ms 5468 KB Output is correct
4 Correct 46 ms 5816 KB Output is correct
5 Correct 35 ms 5468 KB Output is correct
6 Correct 117 ms 5796 KB Output is correct
7 Correct 51 ms 5788 KB Output is correct
8 Correct 31 ms 5468 KB Output is correct
9 Correct 40 ms 5872 KB Output is correct
10 Correct 39 ms 6056 KB Output is correct
11 Correct 37 ms 5728 KB Output is correct
12 Correct 26 ms 5724 KB Output is correct
13 Correct 95 ms 5724 KB Output is correct
14 Correct 46 ms 6572 KB Output is correct
15 Correct 47 ms 6444 KB Output is correct
16 Correct 27 ms 5468 KB Output is correct
17 Correct 61 ms 8440 KB Output is correct
18 Correct 58 ms 6712 KB Output is correct
19 Correct 37 ms 5684 KB Output is correct
20 Correct 162 ms 5812 KB Output is correct
21 Correct 56 ms 5724 KB Output is correct
22 Correct 36 ms 5468 KB Output is correct
23 Correct 40 ms 5724 KB Output is correct
24 Correct 47 ms 5736 KB Output is correct
25 Correct 37 ms 5724 KB Output is correct
26 Correct 36 ms 5724 KB Output is correct
27 Correct 107 ms 5792 KB Output is correct
28 Correct 81 ms 8084 KB Output is correct
29 Correct 48 ms 6492 KB Output is correct
30 Correct 23 ms 5468 KB Output is correct
31 Correct 86 ms 8276 KB Output is correct
32 Correct 53 ms 6684 KB Output is correct
33 Runtime error 6 ms 10844 KB Execution killed with signal 11
34 Halted 0 ms 0 KB -