結果

問題 No.1601 With Animals into Institute
ユーザー chocoruskchocorusk
提出日時 2021-07-10 14:08:02
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 534 ms / 3,000 ms
コード長 1,610 bytes
コンパイル時間 3,431 ms
コンパイル使用メモリ 194,500 KB
実行使用メモリ 18,280 KB
最終ジャッジ日時 2023-09-14 19:14:49
合計ジャッジ時間 12,175 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,688 KB
testcase_01 AC 3 ms
7,636 KB
testcase_02 AC 3 ms
7,688 KB
testcase_03 AC 9 ms
7,996 KB
testcase_04 AC 10 ms
8,220 KB
testcase_05 AC 9 ms
7,948 KB
testcase_06 AC 514 ms
18,076 KB
testcase_07 AC 515 ms
18,160 KB
testcase_08 AC 513 ms
18,092 KB
testcase_09 AC 510 ms
18,264 KB
testcase_10 AC 525 ms
18,140 KB
testcase_11 AC 534 ms
18,112 KB
testcase_12 AC 523 ms
18,244 KB
testcase_13 AC 525 ms
18,256 KB
testcase_14 AC 520 ms
18,248 KB
testcase_15 AC 515 ms
18,280 KB
testcase_16 AC 498 ms
18,272 KB
testcase_17 AC 495 ms
18,072 KB
testcase_18 AC 9 ms
7,984 KB
testcase_19 AC 9 ms
8,008 KB
testcase_20 AC 9 ms
8,008 KB
testcase_21 AC 9 ms
8,036 KB
testcase_22 AC 9 ms
7,984 KB
testcase_23 AC 9 ms
7,980 KB
testcase_24 AC 10 ms
8,000 KB
testcase_25 AC 9 ms
8,164 KB
testcase_26 AC 9 ms
8,004 KB
testcase_27 AC 3 ms
7,632 KB
testcase_28 AC 3 ms
7,632 KB
testcase_29 AC 3 ms
7,648 KB
testcase_30 AC 3 ms
7,676 KB
testcase_31 AC 3 ms
7,648 KB
testcase_32 AC 3 ms
7,760 KB
testcase_33 AC 2 ms
7,632 KB
testcase_34 AC 3 ms
7,924 KB
testcase_35 AC 3 ms
7,768 KB
testcase_36 AC 3 ms
7,792 KB
testcase_37 AC 3 ms
7,700 KB
testcase_38 AC 3 ms
7,640 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;
ll d[2][100010];
int n, m;
vector<P> g[100010];
int a[200010], b[200010];
ll c[200010];
int x[200010];
const ll INF=1e18;
int main()
{
    cin>>n>>m;
    for(int i=0; i<m; i++){
        cin>>a[i]>>b[i]>>c[i]>>x[i];
        a[i]--; b[i]--;
        g[a[i]].push_back({b[i], i});
        g[b[i]].push_back({a[i], i});
    }
    fill(d[0], d[0]+n, INF);
    fill(d[1], d[1]+n, INF);
    d[0][n-1]=0;
    using Pl=pair<ll, P>;
    priority_queue<Pl, vector<Pl>, greater<Pl>> que;
    que.push({0, {n-1, 0}});
    while(!que.empty()){
        auto p=que.top(); que.pop();
        int x1=p.second.first;
        int t=p.second.second;
        if(p.first>d[t][x1]) continue;
        for(auto q:g[x1]){
            int y1=q.first;
            int i=q.second;
            if(d[x[i]|t][y1]>d[t][x1]+c[i]){
                d[x[i]|t][y1]=d[t][x1]+c[i];
                que.push({d[x[i]|t][y1], {y1, (x[i]|t)}});
            }
        }
    }
    for(int i=0; i<n-1; i++){
        cout<<d[1][i]<<endl;
    }
    return 0;
}
0