func_code_string: #include <bits/stdc++.h>   using namespace std;   const int imax = 1e9 + 7;   const long long lmax = 1e18;   const int maxn = 2005;   int P[maxn], C[maxn], A[maxn];   vector<int> adj[maxn];   vector<int> dfs(int cur) {     vector<int> ans(0), v(0);     for (int next : adj[cur]) {       v = dfs(next);       ans.insert(ans.end(), v.begin(), v.end());     }     if (((int)ans.size()) < C[cur]) {       cout <<  NO n ;       exit(0);     }     ans.insert(ans.begin() + C[cur], cur);     return ans;   }   int calc() {     int i, n;     cin >> n;     for (i = 0; i < maxn; ++i) adj[i].clear();     for (i = 1; i < n + 1; ++i) {       cin >> P[i] >> C[i];       adj[P[i]].push_back(i);     }     vector<int> v = dfs(adj[0][0]);     for (i = 0; i < ((int)v.size()); ++i) {       A[v[i]] = i + 1;     }     cout <<  YES n ;     for (i = 1; i < n + 1; ++i) cout << A[i] <<    n [i == n];     return 0;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     calc();     return 0;   }   