結果

問題 No.1 道のショートカット
ユーザー kappybarkappybar
提出日時 2020-06-21 17:58:32
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,668 bytes
コンパイル時間 1,820 ms
コンパイル使用メモリ 177,900 KB
実行使用メモリ 27,668 KB
最終ジャッジ日時 2023-09-22 13:49:47
合計ジャッジ時間 4,318 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 3 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 3 ms
4,380 KB
testcase_07 AC 3 ms
4,380 KB
testcase_08 AC 29 ms
12,524 KB
testcase_09 AC 24 ms
11,312 KB
testcase_10 AC 28 ms
16,672 KB
testcase_11 AC 41 ms
20,308 KB
testcase_12 AC 45 ms
15,240 KB
testcase_13 AC 43 ms
14,820 KB
testcase_14 AC 4 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 WA -
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 7 ms
5,392 KB
testcase_19 AC 10 ms
5,128 KB
testcase_20 AC 14 ms
7,668 KB
testcase_21 WA -
testcase_22 AC 9 ms
5,176 KB
testcase_23 AC 94 ms
27,668 KB
testcase_24 AC 101 ms
22,640 KB
testcase_25 AC 26 ms
8,768 KB
testcase_26 AC 20 ms
7,372 KB
testcase_27 AC 57 ms
19,884 KB
testcase_28 AC 3 ms
4,376 KB
testcase_29 AC 35 ms
23,576 KB
testcase_30 AC 10 ms
8,976 KB
testcase_31 AC 17 ms
13,160 KB
testcase_32 AC 21 ms
10,248 KB
testcase_33 AC 17 ms
9,224 KB
testcase_34 AC 32 ms
15,644 KB
testcase_35 AC 16 ms
13,508 KB
testcase_36 AC 22 ms
15,236 KB
testcase_37 WA -
testcase_38 AC 4 ms
4,776 KB
testcase_39 WA -
testcase_40 AC 13 ms
9,064 KB
testcase_41 AC 6 ms
5,492 KB
testcase_42 AC 2 ms
4,376 KB
testcase_43 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

int n = 55 * 305;
int m;
vector<vector<pll>> graph(n,vector<pll>());

vector<ll>  Dijkstra(int start){
    vector<bool> seen(55 * 305,false);
    vector<ll> shortest(55 * 305,LINF);
    priority_queue<pll,vector<pll>,greater<pll>> pq;
    pq.push(pll(0,start));

    while(!pq.empty()){
        ll dist = pq.top().first;
        int node = pq.top().second;
        pq.pop();
        if(seen[node]) continue;

        shortest[node] = dist;
        seen[node] = true;

        for(pll next:graph[node]){
            int next_node = next.second;
            ll next_cost = next.first;
            if(seen[next_node]) continue;
            pq.push(pll(next_cost + dist,next_node));
        }
    }

    return shortest;
}

int main(){
    cin >> n;
    int c;
    cin >> c;
    cin >> m;
    vector<int> a(m),b(m),y(m),t(m);
    rep(i,m) cin >> a[i],--a[i];
    rep(i,m) cin >> b[i],--b[i];
    rep(i,m) cin >> y[i];
    rep(i,m) cin >> t[i];
    rep(i,m){
        for(int j=y[i];j<=300;j++){
            graph[a[i]*301+j].push_back(pll(t[i],b[i]*301+j-y[i]));
            graph[b[i]*301+j].push_back(pll(t[i],a[i]*301+j-y[i]));
        }
    }

    vector<ll> answer = Dijkstra(0 + c);
    ll ans = LINF;
    rep(i,c+1){
        ans = min(ans,answer[(n-1)*301+i]);
    }
    if(ans==LINF) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}
0