結果
問題 |
No.468 役に立つ競技プログラミング実践編
|
ユーザー |
|
提出日時 | 2016-12-18 00:35:17 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,617 bytes |
コンパイル時間 | 3,211 ms |
コンパイル使用メモリ | 176,736 KB |
実行使用メモリ | 28,444 KB |
最終ジャッジ日時 | 2024-12-14 04:48:49 |
合計ジャッジ時間 | 35,045 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 7 WA * 14 TLE * 10 |
other | AC * 6 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i)) #define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr) #define all(x) (x).begin(),(x).end() #define pb push_back #define fi first #define se second typedef pair<int,int> pi; const int N=100000; const int INF=1010101010; struct edge{ int to,cost; }; vector<edge> G[N],rG[N]; int d[N],rd[N]; int main() { int n,m; scanf(" %d %d", &n, &m); rep(i,m) { int a,b,c; scanf(" %d %d %d", &a, &b, &c); G[a].pb(edge{b,c}); rG[b].pb(edge{a,c}); } // dijkstra priority_queue<pi,vector<pi>,greater<pi>> que; fill(d,d+N,0); que.push(pi(0,0)); while(!que.empty()) { pi p=que.top(); que.pop(); int v=p.se; if(d[v]>p.fi) continue; rep(i,G[v].size()) { edge e=G[v][i]; if(d[e.to]<d[v]+e.cost) { d[e.to]=d[v]+e.cost; que.push(pi(d[e.to],e.to)); } } } fill(rd,rd+N,0); que.push(pi(0,n-1)); while(!que.empty()) { pi p=que.top(); que.pop(); int v=p.se; if(rd[v]>p.fi) continue; rep(i,rG[v].size()) { edge e=rG[v][i]; if(rd[e.to]<rd[v]+e.cost) { rd[e.to]=rd[v]+e.cost; que.push(pi(rd[e.to],e.to)); } } } int ct=0; rep(i,n) ct+=(d[i]==d[n-1]-rd[i]); printf("%d %d/%d\n", d[n-1], n-ct, n); return 0; }