結果
| 問題 |
No.1601 With Animals into Institute
|
| コンテスト | |
| ユーザー |
cureskol
|
| 提出日時 | 2021-07-10 14:09:20 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 626 ms / 3,000 ms |
| コード長 | 1,007 bytes |
| コンパイル時間 | 1,791 ms |
| コンパイル使用メモリ | 177,168 KB |
| 実行使用メモリ | 34,292 KB |
| 最終ジャッジ日時 | 2024-07-02 02:15:56 |
| 合計ジャッジ時間 | 11,428 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 36 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) v.begin(),v.end()
using ll=long long;
const long long LINF=1e18;
typedef pair<ll,ll> P;
int main(){
int n,m;cin>>n>>m;
vector<int> a(m),b(m),c(m),x(m);
REP(i,m)cin>>a[i]>>b[i]>>c[i]>>x[i];
vector<P> g[n*2];
REP(i,m)a[i]--,b[i]--;
REP(i,m){
g[a[i]].push_back(P(b[i],c[i]));
g[b[i]].push_back(P(a[i],c[i]));
g[a[i]+n].push_back(P(b[i]+n,c[i]));
g[b[i]+n].push_back(P(a[i]+n,c[i]));
if(x[i])g[a[i]].push_back(P(b[i]+n,c[i]));
if(x[i])g[b[i]].push_back(P(a[i]+n,c[i]));
}
vector<ll> d(n*2,LINF);
d[n-1]=0;
priority_queue<P,vector<P>,greater<P>> que;
que.push(P(0,n-1));
while(que.size()){
P p=que.top();que.pop();
ll idx=p.second,va=p.first;
if(d[idx]<va)continue;
for(P p:g[idx]){
if(d[p.first]>va+p.second){
d[p.first]=va+p.second;
que.push(P(d[p.first],p.first));
}
}
}
REP(i,n-1)cout<<d[n+i]<<endl;
}
cureskol