제출 #1022063

#제출 시각아이디문제언어결과실행 시간메모리
1022063AlmontherValley (BOI19_valley)C++98
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>

#define suiii ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define co cout<<
//#pragma GCC optimize("O3,Ofast,unroll-loops")
//#pragma GCC target("avx2,sse3,sse4,avx")
using namespace std;
//stuff
ll n,s,q,e;
const ll maxn=1e5+5,N=exp2(ceil(log2(maxn)));
vector<array<ll,3>>v[maxn];
vector<ll>shops;
ll tre[N*4];
ll num=1;
pair<ll,ll>node[maxn]={};
pair<ll,ll>par[maxn];
ll depth[maxn];
vector<pair<ll,ll>>theroads;
pair<ll,ll>tab[maxn][20];
void dfs(ll x){
    node[x]={num,0};
    depth[x]=depth[par[x].first]+1;
    num++;
    for(auto i:v[x]){
        if(i[1]==par[x].first) continue;
        par[i[1]]={node[x].first,i[2]};
        dfs(i[1]);
    }
    node[x]={node[x].first,num};
}
void maketable(ll x){
    if(x==0){
        for(int i=1;i<=n;i++){
            tab[i][x]=par[i];
        }
    }
    else{
        for(int i=1;i<=n;i++){
            tab[i][x].first=tab[tab[i][x-1].first][x-1].first;
            tab[i][x].second=tab[i][x-1].second+tab[tab[i][x-1].first][x-1].second;
        }
    }
}
pair<ll,ll>lca(ll a,ll b){
    ll diff=abs(depth[a]-depth[b]);
    ll ans=0;
    if(diff){
        if(depth[a]<depth[b]){
            ll curr=b;
            for(int i=19;i>=0;i--){
                if(((1<<i)&diff)>0){
                    ans+=tab[curr][i].second;
                    curr=tab[curr][i].first;
                }
            }
            b=curr;
        }
        else if(depth[a]>depth[b]){
            ll curr=a;
            for(int i=19;i>=0;i--){
                if(((1<<i)&diff)>0){
                    ans+=tab[curr][i].second;
                    curr=tab[curr][i].first;
                }
            }
            a=curr;
        }
    }
    if(a==b) return {a,ans};
    for(int i=19;i>=0;i--){
        if(tab[a][i].first!=tab[b][i].first&&tab[a][i].first!=0&&tab[b][i].first!=0){
            ans+=tab[a][i].second;
            a=tab[a][i].first;
            ans+=tab[b][i].second;
            b=tab[b][i].first;
        }
    }
    return {par[a].first,ans+par[a].second};
}
void solve(){
    cin>>n>>s>>q>>e;
    theroads.push_back({-1,-1});
    for(int i=1;i<n;i++){
        ll a,b,c;
        cin>>a>>b>>c;
        v[a].push_back({c,b,i});
        v[b].push_back({c,a,i});
        theroads.push_back({a,b});
    }
    par[1]={0,0};
    dfs(1);
    for(int i=0;i<s;i++){
        ll a;
        cin>>a;
        shops.push_back(node[a].first);
    }
    sort(shops.begin(),shops.end());
    for(int i=0;i<=19;i++) maketable(i);
    while(q--){
        ll del,idx;
        cin>>del>>idx;
        ll copy=node[idx].first;
        ll copy1=node[e].first;
        ll a,b;
        a=node[theroads[del].first].first;
        b=node[theroads[del].second].first;
        if(depth[a]<depth[b]) swap(a,b);
        if((lca(a,copy).first==a&&lca(a,copy1).first==a)||(lca(a,copy).first!=a&&lca(a,copy1).first!=a)){
            co "escaped\n";
        }
        else{
            ll dis=1e18;
            if(lca(a,copy).first==a){
                auto it=lower_bound()
            }
            else{
                if(copy!=n){
                    if(lca(a,copy+1).first!=a){
                        dis=min(dis,lca(copy,copy+1).second);
                    }
                }
                if(copy!=1){
                    if(lca(a,copy-1).first!=a){
                        dis=min(dis,lca(copy,copy-1).second);
                    }
                }
            }
            co 0<<'\n';
        }
    }
}
int main()
{
    suiii
    int tt=1;
    // cin>>tt;
    while(tt--){
        solve();
    }
    return 0;
}

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

valley.cpp: In function 'void solve()':
valley.cpp:115:37: error: no matching function for call to 'lower_bound()'
  115 |                 auto it=lower_bound()
      |                                     ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from valley.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:1350:5: note: candidate: 'template<class _ForwardIterator, class _Tp> _ForwardIterator std::lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&)'
 1350 |     lower_bound(_ForwardIterator __first, _ForwardIterator __last,
      |     ^~~~~~~~~~~
/usr/include/c++/10/bits/stl_algobase.h:1350:5: note:   template argument deduction/substitution failed:
valley.cpp:115:37: note:   candidate expects 3 arguments, 0 provided
  115 |                 auto it=lower_bound()
      |                                     ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from valley.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:2031:5: note: candidate: 'template<class _FIter, class _Tp, class _Compare> _FIter std::lower_bound(_FIter, _FIter, const _Tp&, _Compare)'
 2031 |     lower_bound(_ForwardIterator __first, _ForwardIterator __last,
      |     ^~~~~~~~~~~
/usr/include/c++/10/bits/stl_algo.h:2031:5: note:   template argument deduction/substitution failed:
valley.cpp:115:37: note:   candidate expects 4 arguments, 0 provided
  115 |                 auto it=lower_bound()
      |                                     ^
valley.cpp:116:13: error: expected ',' or ';' before '}' token
  116 |             }
      |             ^