Submission #1237071

#TimeUsernameProblemLanguageResultExecution timeMemory
1237071PlayVoltzRobot (JOI21_ho_t4)C++20
0 / 100
253 ms24040 KiB
#include <cstdio> #include <stdio.h> #include <stdbool.h> #include <iostream> #include <map> #include <vector> #include <climits> #include <stack> #include <string> #include <queue> #include <algorithm> #include <set> #include <unordered_set> #include <unordered_map> #include <cmath> #include <cctype> #include <bitset> #include <iomanip> #include <cstring> #include <numeric> #include <cassert> #include <random> #include <chrono> #include <fstream> using namespace std; #define int long long #define pii pair<int, int> #define mp make_pair #define pb push_back #define fi first #define se second struct trio{ int to, t, c; }; int32_t main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, m, a, b, c, d; cin>>n>>m; vector<vector<trio> > graph(n+1); while (m--){ cin>>a>>b>>c>>d; graph[a].pb({b, c, d}); graph[b].pb({a, c, d}); } vector<int> dj(n+1, LLONG_MAX/2); priority_queue<pii, vector<pii>, greater<pii> > pq; pq.push(mp(0, 1)); while (pq.size()){ int d=pq.top().fi, node=pq.top().se; pq.pop(); if (d>=dj[node])continue; dj[node]=d; map<int, int> m; for (auto num:graph[node])m[num.t]+=num.c; for (auto num:graph[node])pq.push(mp(d+min(num.c, m[num.t]-num.c), num.to)); } cout<<(dj[n]==LLONG_MAX/2?-1:dj[n]); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...