Language: C++

#include<bits/stdc++.h>
using namespace std;
const ll MAX = 2e5+10;
ll n;
ll len;
ll u0,v0;
ll a[MAX];
ll ans[MAX];
vector<ll> adj[MAX];
vector< stack<ll> > dp(MAX);

void dfs(ll cur,ll par)
{
    bool flag = 0;
    ll ind;
    if(a[cur] < dp[1].top())
    {
        dp[1].push(a[cur]);
        ind = 1;
    }
    else if(a[cur] > dp[len].top())
    {
        len++;
        flag = true;
        dp[len].push(a[cur]);
        ind = len;
    }
    else
    {
        ll left = 2;
        ll right = len;
        while(left<=right)
        {
            ll mid = (left+right)/2;
            if(dp[mid].top() > a[cur])
            {
                right = mid-1;
            }
            else left = mid+1;
        }
        ind = right+1;
        dp[ind].push(a[cur]);
    }
    ans[cur] = len;
    for(ll i=0;i<adj[cur].size();i++)
    {
        if(adj[cur][i] == par)continue;
        dfs(adj[cur][i],cur);
    }
    dp[ind].pop();
    len-=flag;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    for(ll i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    for(ll i=1;i<n;i++)
    {
        cin>>u0>>v0;
        adj[u0].push_back(v0);
        adj[v0].push_back(u0);
    }
    dp[1].push(a[1]);
    len = 1;
    ans[1] = 1;
    for(ll j=0; j<adj[1].size(); j++)
    {
        dfs(adj[1][j],1);
    }
    for(ll j=1; j<=n; j++)
    {
        cout<<ans[j]<<endl;
    }
    return 0;
}


Compiler output:
a.cc:3:7: error: 'll' does not name a type
    3 | const ll MAX = 2e5+10;
      |       ^~
a.cc:4:1: error: 'll' does not name a type
    4 | ll n;
      | ^~
a.cc:5:1: error: 'll' does not name a type
    5 | ll len;
      | ^~
a.cc:6:1: error: 'll' does not name a type
    6 | ll u0,v0;
      | ^~
a.cc:7:1: error: 'll' does not name a type
    7 | ll a[MAX];
      | ^~
a.cc:8:1: error: 'll' does not name a type
    8 | ll ans[MAX];
      | ^~
a.cc:9:8: error: 'll' was not declared in this scope
    9 | vector<ll> adj[MAX];
      |        ^~
a.cc:9:10: error: template argument 1 is invalid
    9 | vector<ll> adj[MAX];
      |          ^
a.cc:9:10: error: template argument 2 is invalid
a.cc:9:16: error: 'MAX' was not declared in this scope
    9 | vector<ll> adj[MAX];
      |                ^~~
a.cc:10:15: error: 'll' was not declared in this scope
   10 | vector< stack<ll> > dp(MAX);
      |               ^~
a.cc:10:17: error: template argument 1 is invalid
   10 | vector< stack<ll> > dp(MAX);
      |                 ^
a.cc:10:17: error: template argument 2 is invalid
a.cc:10:19: error: template argument 1 is invalid
   10 | vector< stack<ll> > dp(MAX);
      |                   ^
a.cc:10:19: error: template argument 2 is invalid
a.cc:10:24: error: 'MAX' was not declared in this scope
   10 | vector< stack<ll> > dp(MAX);
      |                        ^~~
a.cc:12:6: error: variable or field 'dfs' declared void
   12 | void dfs(ll cur,ll par)
      |      ^~~
a.cc:12:10: error: 'll' was not declared in this scope
   12 | void dfs(ll cur,ll par)
      |          ^~
a.cc:12:17: error: 'll' was not declared in this scope
   12 | void dfs(ll cur,ll par)
      |                 ^~
a.cc: In function 'int main()':
a.cc:57:10: error: 'n' was not declared in this scope; did you mean 'yn'?
   57 |     cin>>n;
      |          ^
      |          yn
a.cc:58:9: error: 'll' was not declared in this scope
   58 |     for(ll i=1;i<=n;i++)
      |         ^~
a.cc:58:16: error: 'i' was not declared in this scope
   58 |     for(ll i=1;i<=n;i++)
      |                ^
a.cc:60:14: error: 'a' was not declared in this scope
   60 |         cin>>a[i];
      |              ^
a.cc:62:9: error: 'll' was not declared in this scope
   62 |     for(ll i=1;i<n;i++)
      |         ^~
a.cc:62:16: error: 'i' was not declared in this scope
   62 |     for(ll i=1;i<n;i++)
      |                ^
a.cc:64:14: error: 'u0' was not declared in this scope; did you mean 'y0'?
   64 |         cin>>u0>>v0;
      |              ^~
      |              y0
a.cc:64:18: error: 'v0' was not declared in this scope; did you mean 'y0'?
   64 |         cin>>u0>>v0;
      |                  ^~
      |                  y0
a.cc:65:9: error: 'adj' was not declared in this scope
   65 |         adj[u0].push_back(v0);
      |         ^~~
a.cc:68:7: error: invalid types 'int[int]' for array subscript
   68 |     dp[1].push(a[1]);
      |       ^
a.cc:68:16: error: 'a' was not declared in this scope
   68 |     dp[1].push(a[1]);
      |                ^
a.cc:69:5: error: 'len' was not declared in this scope
   69 |     len = 1;
      |     ^~~
a.cc:70:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
   70 |     ans[1] = 1;
      |     ^~~
      |     abs
a.cc:71:9: error: 'll' was not declared in this scope
   71 |     for(ll j=0; j<adj[1].size(); j++)
      |         ^~
a.cc:71:17: error: 'j' was not declared in this scope; did you mean 'jn'?
   71 |     for(ll j=0; j<adj[1].size(); j++)
      |                 ^
      |                 jn
a.cc:71:19: error: 'adj' was not declared in this scope
   71 |     for(ll j=0; j<adj[1].size(); j++)
      |                   ^~~
a.cc:73:9: error: 'dfs' was not declared in this scope; did you mean 'ffs'?
   73 |         dfs(adj[1][j],1);
      |         ^~~
      |         ffs
a.cc:75:9: error: 'll' was not declared in this scope
   75 |     for(ll j=1; j<=n; j++)
      |         ^~
a.cc:75:17: error: 'j' was not declared in this scope; did you mean 'jn'?
   75 |     for(ll j=1; j<=n; j++)
      |                 ^
      |                 jn