func_code_string: #include <bits/stdc++.h>   using namespace std;   vector<long long> adj[100001];   long long vis[100001] = {0};   long long n;   long long nodecolor[100001];   long long treecolor[100001];   long long cc[100001];   map<long long, long long> colorcnt;   long long dfs(long long root, long long col) {     long long cnt = 1;     vis[root] = 1;     treecolor[root] = nodecolor[root];     for (auto x : adj[root]) {       if (vis[x] == 0 && nodecolor[x] != col) treecolor[root] = -1;     }     long long flag = 0;     for (auto x : adj[root]) {       if (vis[x] == 0) {         flag = 1;         cnt += dfs(x, nodecolor[x]);         if (treecolor[x] != nodecolor[root]) treecolor[root] = -1;       }     }     if (flag == 0) {       treecolor[root] = nodecolor[root];     }     return cc[root] = cnt;   }   long long fun(long long root) {     vis[root] = 1;     long long flag = 0;     set<long long> st;     long long parentcolor = -1;     for (auto x : adj[root]) {       if (vis[x] == 0) {         if (treecolor[x] == -1) flag = 1;       } else {         parentcolor = nodecolor[x];       }     }     if (flag == 0) {       if (parentcolor == -1) return root;       for (auto x : adj[root]) {         if (vis[x] == 0) {           colorcnt[treecolor[x]] -= cc[x];         }       }       colorcnt[nodecolor[root]]--;       if (colorcnt[parentcolor] == n - cc[root]) {         return root;       }       for (auto x : adj[root]) {         if (vis[x] == 0) {           colorcnt[treecolor[x]] += cc[x];         }       }       colorcnt[nodecolor[root]]++;     }     long long ans = -1;     for (auto x : adj[root]) {       if (vis[x] == 0) {         ans = fun(x);         if (ans != -1) return ans;       }     }     return ans;   }   void solve(long long cno) {     long long m, i, j, k, l;     cin >> n;     long long flag = 0;     for (i = 0; i < n - 1; i++) {       cin >> j >> k;       j--;       k--;       adj[j].push_back(k);       adj[k].push_back(j);     }     for (i = 0; i < n; i++) {       cin >> nodecolor[i];       colorcnt[nodecolor[i]]++;     }     long long temp = dfs(0, nodecolor[0]);     for (i = 0; i < n; i++) vis[i] = 0;     long long ans = -1;     ans = fun(0);     if (ans == -1)       cout <<  NO ;     else {       cout <<  YES  <<   n  << ans + 1;     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int TESTS = 1;     long long i = 1;     while (TESTS--) {       solve(i);       i++;     }     return 0;   }   