結果
| 問題 |
No.1601 With Animals into Institute
|
| コンテスト | |
| ユーザー |
chocorusk
|
| 提出日時 | 2021-07-10 14:07:40 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,610 bytes |
| コンパイル時間 | 4,029 ms |
| コンパイル使用メモリ | 187,324 KB |
| 最終ジャッジ日時 | 2025-01-23 00:03:37 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 24 RE * 12 |
ソースコード
#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[100010], b[100010];
ll c[100010];
int x[100010];
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;
}
chocorusk