結果

問題 No.468 役に立つ競技プログラミング実践編
ユーザー imulanimulan
提出日時 2016-12-18 00:35:17
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,617 bytes
コンパイル時間 2,115 ms
コンパイル使用メモリ 175,872 KB
実行使用メモリ 25,896 KB
最終ジャッジ日時 2024-05-08 04:23:07
合計ジャッジ時間 7,220 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
16,232 KB
testcase_01 AC 3 ms
9,164 KB
testcase_02 AC 3 ms
9,096 KB
testcase_03 AC 4 ms
9,156 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 3 ms
9,024 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 30 ms
9,152 KB
testcase_19 AC 29 ms
9,144 KB
testcase_20 WA -
testcase_21 AC 26 ms
9,212 KB
testcase_22 AC 24 ms
9,112 KB
testcase_23 AC 28 ms
9,160 KB
testcase_24 TLE -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0