제출 #1327383

#제출 시각아이디문제언어결과실행 시간메모리
1327383madtValley (BOI19_valley)C++20
0 / 100
3094 ms9384 KiB
#include <bits/stdc++.h>
#define pii pair<int, int>
#define fi first
#define se second
#define ll long long

using namespace std;

const int INF = 1e18+8;
vector<array<ll, 3>> edges[100'002];
bool shop[100'002];
ll e;

ll dfs(ll u, ll block, ll p=0, ll dist=0){
    if(u==e)
        return -1;

    ll tta;
    if(shop[u])
        tta=dist;
    else tta=INF;

    for(auto x : edges[u]){
        if(x[0]!=p && x[2]!=block){
            tta=min(tta, dfs(x[0], block, u, dist+x[1]));
        }
    }
    return tta;
}

int main()
{
    ll n, s, q; cin>>n>>s>>q>>e;

    for(ll i=1; i<n; i++){
        ll a, b, w; cin>>a>>b>>w;
        edges[a].push_back({b, w, i});
        edges[b].push_back({a, w, i});
    }

    for(ll i=0; i<s; i++){
        ll s; cin>>s;
        shop[s]=1;
    }

    for(ll i=0; i<q; i++){
        ll u, block; cin>>block>>u;
        ll atb = dfs(u, block);
        if(atb==-1)
            cout<<"escaped"<<endl;
        else if(atb==INF)
            cout<<"oo"<<endl;
        else
            cout<<atb<<endl;
    }

    return 0;
}

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

valley.cpp:9:21: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
    9 | const int INF = 1e18+8;
      |                 ~~~~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...