제출 #699500

#제출 시각아이디문제언어결과실행 시간메모리
699500jiahngRobot (JOI21_ho_t4)C++14
0 / 100
285 ms81232 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define int ll typedef pair<int, int> pi; typedef vector <int> vi; typedef vector <pi> vpi; typedef pair <pi,pi> pipi; typedef pair<pi, ll> pii; typedef set <ll> si; typedef long double ld; #define f first #define s second #define mp make_pair #define FOR(i,s,e) for(int i=s;i<=int(e);++i) #define DEC(i,s,e) for(int i=s;i>=int(e);--i) #define pb push_back #define all(x) (x).begin(), (x).end() #define lbd(x, y) lower_bound(all(x), y) #define ubd(x, y) upper_bound(all(x), y) #define aFOR(i,x) for (auto i: x) #define mem(x,i) memset(x,i,sizeof x) #define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0) #define maxn 1000010 #define INF (ll)1e18 #define MOD 1000000007 typedef pair <vi, int> pvi; typedef pair <int,pi> ipi; typedef vector <pii> vpii; #define DEBUG 0 int N,M; int a,b,c,p; int sm[maxn]; vector <ipi> adj[maxn]; vector <pi> adj2[maxn]; int dist[maxn]; int32_t main(){ cin >> N >> M; FOR(i,1,M){ cin >> a >> b >> c >> p; adj[a].pb(ipi(b, pi(c,p))); adj[b].pb(ipi(a,pi(c,p))); } FOR(i,1,N){ aFOR(j, adj[i]) sm[j.s.f] += j.s.s; aFOR(j, adj[i]){ adj2[i].pb(pi(j.f, min(j.s.s, sm[j.s.f] - j.s.s))); } aFOR(j, adj[i]) sm[j.s.f] = 0; } priority_queue <pi,vector <pi>, greater <pi> > pq; pq.push(pi(0,1)); mem(dist,-1); dist[1] = 0; while (!pq.empty()){ pi x = pq.top(); pq.pop(); //cout << x.s << '\n'; if (x.f != dist[x.s]) continue; aFOR(i, adj2[x.s]){ if (dist[i.f] == -1 || dist[i.f] > x.f + i.s){ dist[i.f] = x.f + i.s; pq.push(pi(dist[i.f], i.f)); } } } cout << dist[N]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...