Submission #924486

#TimeUsernameProblemLanguageResultExecution timeMemory
924486Muhammad_AneeqToll (BOI17_toll)C++17
0 / 100
3081 ms6024 KiB
/* بسم الله الرحمن الرحيم Author: (:Muhammad Aneeq:) */ #include <iostream> #include <vector> #include <queue> #include <map> using namespace std; map<pair<int,int>,int>d; int const N=5e4+10; vector<pair<int,int>>nei[N]={}; int dist[N]={}; bool vis[N]={}; int ans=0; void dfs(int n,int v,int cost=0) { if (n>v) return ; if (n==v) { ans=min(ans,cost); return; } for (auto [j,w]:nei[n]) dfs(j,v,cost+w); } inline void solve() { int n,m,k,o; cin>>k>>n>>m>>o; while (m--) { int a,b,t; cin>>a>>b>>t; nei[a].push_back({b,t}); } vector<pair<int,int>>ord; while (o--) { int x,y; cin>>x>>y; ans=1e9+10; dfs(x,y); cout<<(ans==1e9+10?-1:ans)<<endl; } } int main() { ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); solve(); }
#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...