結果

問題 No.1601 With Animals into Institute
ユーザー seven_threeseven_three
提出日時 2021-07-10 18:11:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,382 bytes
コンパイル時間 945 ms
コンパイル使用メモリ 108,492 KB
実行使用メモリ 16,680 KB
最終ジャッジ日時 2023-09-14 19:46:57
合計ジャッジ時間 9,754 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
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 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 4 ms
5,144 KB
testcase_28 AC 4 ms
5,360 KB
testcase_29 AC 3 ms
5,112 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 4 ms
5,220 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 3 ms
5,268 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
long long v[100010][2];
vector<vector<tuple<int, int, int>>> vec(100010);
long long inf = 1000000000000007;
int main() {
	long long n, m;
	cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < 2; j++) {
			v[i][j] = inf;
		}
	}
	for (int i = 0; i < m; i++) {
		long long a, b, c, x;
		cin >> a >> b >> c >> x;
		vec[a].emplace_back(make_tuple(b, c, x));
		vec[b].emplace_back(make_tuple(a, c, x));
	}
	v[n][0] = 0;
	priority_queue<tuple<int, int, int>,vector<tuple<int,int,int>>,greater<tuple<int,int,int>>> que;
	que.push(make_tuple(0, n, 0));
	while (!que.empty()) {
		tuple<int, int, int> t = que.top();
		long long y = get<0>(t);
		long long x = get<1>(t);
		int z = get<2>(t);
		que.pop();
		if (v[x][z] < y) {
			continue;
		}
		for (int i = 0; i < vec[x].size(); i++) {
			tuple<int, int, int> t1 = vec[x][i];
			long long x1 = get<0>(t1);
			long long y1 = get<1>(t1);
			int z1 = get<2>(t1);
			if (v[x1][z|z1] > y + y1) {
				v[x1][z|z1] = y + y1;
				que.push(make_tuple(v[x1][z|z1], x1, z1));
			}
		}
	}
	for (int i = 1; i < n; i++) {
		cout << v[i][1] << endl;
	}
}
0