제출 #1246543

#제출 시각아이디문제언어결과실행 시간메모리
1246543nasjesCat Exercise (JOI23_ho_t4)C++20
컴파일 에러
0 ms0 KiB

#define fi first
#define pb push_back
#define se second
#define vll vector<ll>

ll n, m;
pll h[dim];
vll a[dim];
ll dp[dim], dep[dim], tin[dim], tout[dim];
ll jump[24][dim];
vll g[dim];
ll boss[dim];
ll findboss(ll v){
    if(boss[v]==v)return v;
    return boss[v]=findboss(boss[v]);
}
ll t=0;
void dfs(ll v,ll p,  ll d){
    dep[v]=d;
    t++;
    tin[v]=t;
    jump[0][v]=p;
    for(int i=1; i<=21; i++){
        jump[i][v]=jump[i-1][jump[i-1][v]];
    }
    for( auto x:a[v]){
        if(x==p)continue;
        dfs(x, v, d+1);
    }
    t++;
    tout[v]=t;
}
ll same(ll x, ll y){
    if(tin[x]<=tin[y] && tout[y]<=tout[x])return 1;
    swap(x, y);
    if(tin[x]<=tin[y] && tout[y]<=tout[x])return 1;
    return 0;
}
ll lca(ll x, ll y){
    if(dep[x]>dep[y])swap(x, y);
    ll cur=x;
    if(same(x, y)){
        return x;
    }
    for(int st=20; st>=0; st--){
        if(!same(jump[st][cur], y)){
            cur=jump[st][cur];
        }
    }
   // cout<<cur<<endl;
    return jump[0][cur];
}
ll dst(ll x, ll y){
    ll p1=dep[lca(x, y)];
    return dep[x]+dep[y]-2*p1;

}
void unite(ll x, ll y){
    ll xx=findboss(x);
    boss[xx]=y;
}
int main() {

    ll k, u, v;
    string s;
    cin>>n;
    for(int i=1; i<=n; i++){
        cin>>h[i].fi;
        h[i].se=i;
        dp[i]=0;
        boss[i]=i;
    }
    for(int i=1; i<=n-1; i++){
        cin>>u>>v;
        a[u].pb(v);
        a[v].pb(u);
        if(h[u]<h[v])swap(u, v);
        g[u].pb(v);
    }
    sort(h+1, h+1+n);
    t=0;
    dfs(1, 1, 1);
    for(int i=1; i<=n; i++){
        ll cur=h[i].se;
      // cout<<cur<<" -- ";
        for(auto x:g[cur]){
            ll tmp=findboss(x);
            ll d=dst(cur, tmp);
            //cout<<tmp<<" "<<d<<endl;
            dp[cur]=max(dp[cur], dp[tmp]+d);
        }
       // cout<<dp[cur]<<endl;
        for(auto x:g[cur]){
            unite(x, cur);
        }
    }
    cout<<dp[h[n].se]<<endl;
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp:7:1: error: 'll' does not name a type; did you mean 'vll'?
    7 | ll n, m;
      | ^~
      | vll
Main.cpp:8:1: error: 'pll' does not name a type; did you mean 'vll'?
    8 | pll h[dim];
      | ^~~
      | vll
Main.cpp:5:20: error: 'll' was not declared in this scope; did you mean 'vll'?
    5 | #define vll vector<ll>
      |                    ^~
Main.cpp:9:1: note: in expansion of macro 'vll'
    9 | vll a[dim];
      | ^~~
Main.cpp:5:20: error: 'll' was not declared in this scope; did you mean 'vll'?
    5 | #define vll vector<ll>
      |                    ^~
Main.cpp:9:1: note: in expansion of macro 'vll'
    9 | vll a[dim];
      | ^~~
Main.cpp:5:20: error: 'll' was not declared in this scope; did you mean 'vll'?
    5 | #define vll vector<ll>
      |                    ^~
Main.cpp:9:1: note: in expansion of macro 'vll'
    9 | vll a[dim];
      | ^~~
Main.cpp:5:20: error: 'll' was not declared in this scope; did you mean 'vll'?
    5 | #define vll vector<ll>
      |                    ^~
Main.cpp:9:1: note: in expansion of macro 'vll'
    9 | vll a[dim];
      | ^~~
Main.cpp:5:20: error: 'll' was not declared in this scope; did you mean 'vll'?
    5 | #define vll vector<ll>
      |                    ^~
Main.cpp:9:1: note: in expansion of macro 'vll'
    9 | vll a[dim];
      | ^~~
Main.cpp:5:20: error: 'll' was not declared in this scope; did you mean 'vll'?
    5 | #define vll vector<ll>
      |                    ^~
Main.cpp:9:1: note: in expansion of macro 'vll'
    9 | vll a[dim];
      | ^~~
Main.cpp:5:20: error: 'll' was not declared in this scope; did you mean 'vll'?
    5 | #define vll vector<ll>
      |                    ^~
Main.cpp:9:1: note: in expansion of macro 'vll'
    9 | vll a[dim];
      | ^~~
Main.cpp:5:20: error: 'll' was not declared in this scope; did you mean 'vll'?
    5 | #define vll vector<ll>
      |                    ^~
Main.cpp:9:1: note: in expansion of macro 'vll'
    9 | vll a[dim];
      | ^~~
Main.cpp:5:20: error: 'll' was not declared in this scope; did you mean 'vll'?
    5 | #define vll vector<ll>
      |                    ^~
Main.cpp:9:1: note: in expansion of macro 'vll'
    9 | vll a[dim];
      | ^~~
Main.cpp:5:13: error: 'vector' does not name a type
    5 | #define vll vector<ll>
      |             ^~~~~~
Main.cpp:9:1: note: in expansion of macro 'vll'
    9 | vll a[dim];
      | ^~~
Main.cpp:10:1: error: 'll' does not name a type; did you mean 'vll'?
   10 | ll dp[dim], dep[dim], tin[dim], tout[dim];
      | ^~
      | vll
Main.cpp:11:1: error: 'll' does not name a type; did you mean 'vll'?
   11 | ll jump[24][dim];
      | ^~
      | vll
Main.cpp:5:20: error: 'll' was not declared in this scope; did you mean 'vll'?
    5 | #define vll vector<ll>
      |                    ^~
Main.cpp:12:1: note: in expansion of macro 'vll'
   12 | vll g[dim];
      | ^~~
Main.cpp:5:20: error: 'll' was not declared in this scope; did you mean 'vll'?
    5 | #define vll vector<ll>
      |                    ^~
Main.cpp:12:1: note: in expansion of macro 'vll'
   12 | vll g[dim];
      | ^~~
Main.cpp:5:20: error: 'll' was not declared in this scope; did you mean 'vll'?
    5 | #define vll vector<ll>
      |                    ^~
Main.cpp:12:1: note: in expansion of macro 'vll'
   12 | vll g[dim];
      | ^~~
Main.cpp:5:20: error: 'll' was not declared in this scope; did you mean 'vll'?
    5 | #define vll vector<ll>
      |                    ^~
Main.cpp:12:1: note: in expansion of macro 'vll'
   12 | vll g[dim];
      | ^~~
Main.cpp:5:20: error: 'll' was not declared in this scope; did you mean 'vll'?
    5 | #define vll vector<ll>
      |                    ^~
Main.cpp:12:1: note: in expansion of macro 'vll'
   12 | vll g[dim];
      | ^~~
Main.cpp:5:20: error: 'll' was not declared in this scope; did you mean 'vll'?
    5 | #define vll vector<ll>
      |                    ^~
Main.cpp:12:1: note: in expansion of macro 'vll'
   12 | vll g[dim];
      | ^~~
Main.cpp:5:20: error: 'll' was not declared in this scope; did you mean 'vll'?
    5 | #define vll vector<ll>
      |                    ^~
Main.cpp:12:1: note: in expansion of macro 'vll'
   12 | vll g[dim];
      | ^~~
Main.cpp:5:20: error: 'll' was not declared in this scope; did you mean 'vll'?
    5 | #define vll vector<ll>
      |                    ^~
Main.cpp:12:1: note: in expansion of macro 'vll'
   12 | vll g[dim];
      | ^~~
Main.cpp:5:20: error: 'll' was not declared in this scope; did you mean 'vll'?
    5 | #define vll vector<ll>
      |                    ^~
Main.cpp:12:1: note: in expansion of macro 'vll'
   12 | vll g[dim];
      | ^~~
Main.cpp:5:13: error: 'vector' does not name a type
    5 | #define vll vector<ll>
      |             ^~~~~~
Main.cpp:12:1: note: in expansion of macro 'vll'
   12 | vll g[dim];
      | ^~~
Main.cpp:13:1: error: 'll' does not name a type; did you mean 'vll'?
   13 | ll boss[dim];
      | ^~
      | vll
Main.cpp:14:1: error: 'll' does not name a type; did you mean 'vll'?
   14 | ll findboss(ll v){
      | ^~
      | vll
Main.cpp:18:1: error: 'll' does not name a type; did you mean 'vll'?
   18 | ll t=0;
      | ^~
      | vll
Main.cpp:19:6: error: variable or field 'dfs' declared void
   19 | void dfs(ll v,ll p,  ll d){
      |      ^~~
Main.cpp:19:10: error: 'll' was not declared in this scope; did you mean 'vll'?
   19 | void dfs(ll v,ll p,  ll d){
      |          ^~
      |          vll
Main.cpp:19:15: error: 'll' was not declared in this scope; did you mean 'vll'?
   19 | void dfs(ll v,ll p,  ll d){
      |               ^~
      |               vll
Main.cpp:19:22: error: 'll' was not declared in this scope; did you mean 'vll'?
   19 | void dfs(ll v,ll p,  ll d){
      |                      ^~
      |                      vll
Main.cpp:34:1: error: 'll' does not name a type; did you mean 'vll'?
   34 | ll same(ll x, ll y){
      | ^~
      | vll
Main.cpp:40:1: error: 'll' does not name a type; did you mean 'vll'?
   40 | ll lca(ll x, ll y){
      | ^~
      | vll
Main.cpp:54:1: error: 'll' does not name a type; did you mean 'vll'?
   54 | ll dst(ll x, ll y){
      | ^~
      | vll
Main.cpp:59:6: error: variable or field 'unite' declared void
   59 | void unite(ll x, ll y){
      |      ^~~~~
Main.cpp:59:12: error: 'll' was not declared in this scope; did you mean 'vll'?
   59 | void unite(ll x, ll y){
      |            ^~
      |            vll
Main.cpp:59:18: error: 'll' was not declared in this scope; did you mean 'vll'?
   59 | void unite(ll x, ll y){
      |                  ^~
      |                  vll
Main.cpp: In function 'int main()':
Main.cpp:65:5: error: 'll' was not declared in this scope; did you mean 'vll'?
   65 |     ll k, u, v;
      |     ^~
      |     vll
Main.cpp:66:5: error: 'string' was not declared in this scope
   66 |     string s;
      |     ^~~~~~
Main.cpp:67:5: error: 'cin' was not declared in this scope
   67 |     cin>>n;
      |     ^~~
Main.cpp:67:10: error: 'n' was not declared in this scope
   67 |     cin>>n;
      |          ^
Main.cpp:69:14: error: 'h' was not declared in this scope
   69 |         cin>>h[i].fi;
      |              ^
Main.cpp:71:9: error: 'dp' was not declared in this scope
   71 |         dp[i]=0;
      |         ^~
Main.cpp:72:9: error: 'boss' was not declared in this scope
   72 |         boss[i]=i;
      |         ^~~~
Main.cpp:75:14: error: 'u' was not declared in this scope
   75 |         cin>>u>>v;
      |              ^
Main.cpp:75:17: error: 'v' was not declared in this scope
   75 |         cin>>u>>v;
      |                 ^
Main.cpp:76:9: error: 'a' was not declared in this scope
   76 |         a[u].pb(v);
      |         ^
Main.cpp:78:12: error: 'h' was not declared in this scope
   78 |         if(h[u]<h[v])swap(u, v);
      |            ^
Main.cpp:78:22: error: 'swap' was not declared in this scope
   78 |         if(h[u]<h[v])swap(u, v);
      |                      ^~~~
Main.cpp:79:9: error: 'g' was not declared in this scope
   79 |         g[u].pb(v);
      |         ^
Main.cpp:81:10: error: 'h' was not declared in this scope
   81 |     sort(h+1, h+1+n);
      |          ^
Main.cpp:81:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   81 |     sort(h+1, h+1+n);
      |     ^~~~
      |     short
Main.cpp:82:5: error: 't' was not declared in this scope
   82 |     t=0;
      |     ^
Main.cpp:83:5: error: 'dfs' was not declared in this scope
   83 |     dfs(1, 1, 1);
      |     ^~~
Main.cpp:85:11: error: expected ';' before 'cur'
   85 |         ll cur=h[i].se;
      |           ^~~~
      |           ;
Main.cpp:87:20: error: 'g' was not declared in this scope
   87 |         for(auto x:g[cur]){
      |                    ^
Main.cpp:87:22: error: 'cur' was not declared in this scope
   87 |         for(auto x:g[cur]){
      |                      ^~~
Main.cpp:88:15: error: expected ';' before 'tmp'
   88 |             ll tmp=findboss(x);
      |               ^~~~
      |               ;
Main.cpp:89:15: error: expected ';' before 'd'
   89 |             ll d=dst(cur, tmp);
      |               ^~
      |               ;
Main.cpp:91:13: error: 'dp' was not declared in this scope
   91 |             dp[cur]=max(dp[cur], dp[tmp]+d);
      |             ^~
Main.cpp:91:37: error: 'tmp' was not declared in this scope
   91 |             dp[cur]=max(dp[cur], dp[tmp]+d);
      |                                     ^~~
Main.cpp:91:42: error: 'd' was not declared in this scope
   91 |             dp[cur]=max(dp[cur], dp[tmp]+d);
      |                                          ^
Main.cpp:91:21: error: 'max' was not declared in this scope
   91 |             dp[cur]=max(dp[cur], dp[tmp]+d);
      |                     ^~~
Main.cpp:94:20: error: 'g' was not declared in this scope
   94 |         for(auto x:g[cur]){
      |                    ^
Main.cpp:94:22: error: 'cur' was not declared in this scope
   94 |         for(auto x:g[cur]){
      |                      ^~~
Main.cpp:95:13: error: 'unite' was not declared in this scope
   95 |             unite(x, cur);
      |             ^~~~~
Main.cpp:98:5: error: 'cout' was not declared in this scope
   98 |     cout<<dp[h[n].se]<<endl;
      |     ^~~~
Main.cpp:98:11: error: 'dp' was not declared in this scope
   98 |     cout<<dp[h[n].se]<<endl;
      |           ^~
Main.cpp:98:24: error: 'endl' was not declared in this scope
   98 |     cout<<dp[h[n].se]<<endl;
      |                        ^~~~