Submission #997930

#TimeUsernameProblemLanguageResultExecution timeMemory
997930Trisanu_DasTrain (APIO24_train)C++17
5 / 100
55 ms18092 KiB
#include <bits/stdc++.h> #define ll long long using namespace std; const int N = 2e5+5; const ll INF = 5e15; vector<array<int, 4> > adj[N]; ll dist[N]; long long solve(int n, int m, int w, vector<int> T, vector<int> X, vector<int> Y, vector<int> A, vector<int> B, vector<int> C, vector<int> L, vector<int> R) { for (int i = 0; i < n; i++) adj[i].clear(); for (int i = 0; i < m; i++) adj[X[i]].push_back({A[i], B[i], Y[i], C[i]}); for (int i = 0; i < n; i++) sort(adj[i].begin(), adj[i].end()); dist[0] = 0; for (int i = 1; i < n; i++) dist[i] = INF; priority_queue<array<ll, 3>, vector<array<ll, 3>>, greater<array<ll, 3>>> pq; pq.push({0, 0, 0}); while (pq.size()) { auto [cost, tim, node] = pq.top(); pq.pop(); if (cost > dist[node]) continue; dist[node] = cost; for (auto [l, r, y, c] : adj[node]) if (l >= tim && cost+c < dist[y]) pq.push({cost+c, r, y}); } return (dist[n-1] == INF ? -1 : dist[n-1]); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...