Submission #934837

#TimeUsernameProblemLanguageResultExecution timeMemory
934837irmuunToll (BOI17_toll)C++17
100 / 100
1975 ms9668 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define ff first #define ss second #define all(s) s.begin(),s.end() #define rall(s) s.rbegin(),s.rend() int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); ll k,n,m,O; cin>>k>>n>>m>>O; vector<pair<ll,ll>>adj[n]; for(ll i=1;i<=m;i++){ ll a,b,t; cin>>a>>b>>t; adj[a].pb({b,t}); } ll dp[n]; for(ll i=1;i<=O;i++){ ll a,b; cin>>a>>b; fill(dp,dp+b+1,1e18); dp[a]=0; for(ll j=a;j<b;j++){ for(auto [y,t]:adj[j]){ dp[y]=min(dp[y],dp[j]+t); } } if(dp[b]==1e18){ cout<<-1<<"\n"; } else{ cout<<dp[b]<<"\n"; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...