結果

問題 No.1601 With Animals into Institute
ユーザー seven_threeseven_three
提出日時 2021-07-10 18:16:15
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,447 bytes
コンパイル時間 1,035 ms
コンパイル使用メモリ 111,244 KB
実行使用メモリ 23,092 KB
最終ジャッジ日時 2023-09-14 19:47:41
合計ジャッジ時間 16,556 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
5,164 KB
testcase_01 AC 4 ms
5,292 KB
testcase_02 AC 4 ms
5,180 KB
testcase_03 AC 9 ms
5,716 KB
testcase_04 AC 10 ms
5,656 KB
testcase_05 AC 10 ms
5,716 KB
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 AC 10 ms
5,804 KB
testcase_19 AC 10 ms
5,824 KB
testcase_20 AC 10 ms
5,768 KB
testcase_21 AC 9 ms
5,836 KB
testcase_22 AC 10 ms
5,848 KB
testcase_23 AC 10 ms
5,912 KB
testcase_24 AC 11 ms
5,840 KB
testcase_25 AC 10 ms
5,860 KB
testcase_26 AC 10 ms
5,844 KB
testcase_27 AC 4 ms
5,300 KB
testcase_28 AC 2 ms
5,220 KB
testcase_29 AC 3 ms
5,180 KB
testcase_30 AC 3 ms
5,348 KB
testcase_31 AC 3 ms
5,372 KB
testcase_32 AC 3 ms
5,268 KB
testcase_33 AC 3 ms
5,348 KB
testcase_34 AC 3 ms
5,200 KB
testcase_35 AC 4 ms
5,368 KB
testcase_36 AC 4 ms
5,300 KB
testcase_37 AC 4 ms
5,292 KB
testcase_38 AC 3 ms
5,120 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<long long, long long, int>,vector<tuple<long long,long long,int>>,greater<tuple<long long,long long,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][0] < y && v[x][1] < y) {
			continue;
		}
		for (int i = 0; i < vec[x].size(); i++) {
			tuple<int, long long, long long> 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, z|z1));
			}
		}
	}
	for (int i = 1; i < n; i++) {
		cout << v[i][1] << endl;
	}
}
0