結果

問題 No.1301 Strange Graph Shortest Path
ユーザー uzzyuzzy
提出日時 2020-11-27 23:33:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,914 bytes
コンパイル時間 1,638 ms
コンパイル使用メモリ 174,856 KB
実行使用メモリ 12,136 KB
最終ジャッジ日時 2023-10-10 21:47:45
合計ジャッジ時間 6,781 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,744 KB
testcase_01 AC 3 ms
5,736 KB
testcase_02 WA -
testcase_03 AC 71 ms
9,592 KB
testcase_04 AC 112 ms
11,668 KB
testcase_05 AC 68 ms
9,796 KB
testcase_06 AC 100 ms
10,940 KB
testcase_07 AC 86 ms
10,676 KB
testcase_08 AC 68 ms
9,532 KB
testcase_09 AC 90 ms
10,720 KB
testcase_10 WA -
testcase_11 AC 94 ms
11,012 KB
testcase_12 AC 97 ms
11,104 KB
testcase_13 AC 83 ms
10,236 KB
testcase_14 AC 88 ms
10,620 KB
testcase_15 AC 87 ms
10,388 KB
testcase_16 AC 129 ms
11,756 KB
testcase_17 AC 95 ms
10,660 KB
testcase_18 AC 82 ms
10,272 KB
testcase_19 AC 103 ms
10,964 KB
testcase_20 AC 112 ms
11,232 KB
testcase_21 AC 93 ms
10,520 KB
testcase_22 AC 117 ms
11,560 KB
testcase_23 AC 88 ms
10,596 KB
testcase_24 AC 117 ms
11,216 KB
testcase_25 AC 105 ms
11,572 KB
testcase_26 AC 90 ms
10,744 KB
testcase_27 AC 92 ms
10,948 KB
testcase_28 AC 71 ms
10,032 KB
testcase_29 WA -
testcase_30 AC 101 ms
11,224 KB
testcase_31 AC 102 ms
11,264 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 87 ms
11,188 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//#pragma GCC optimize ("O2")
//#pragma GCC target ("avx2")
#include<bits/stdc++.h>
//#include<atcoder/all>
//using namespace atcoder;

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

vector<pair<int, int>> E[100001];
int C[100001], D[100001];
pair<int, int> mae[100001];

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);


	int N, M;
	cin >> N >> M;

	rep(i, M) {
		int u, v, c, d;
		cin >> u >> v >> c >> d;
		E[u].pb({ v, i });
		E[v].pb({ u, i });
		C[i] = c;
		D[i] = d;
	}

#define PT pair<ll, int>
	ll Di[100001];
	rep1(i, N) Di[i] = 1e18;

	priority_queue<PT, vector<PT>, greater<PT>> que;
	Di[1] = 0;
	que.push(mp(0, 1));
	while (que.size()) {
		PT p = que.top();
		que.pop();
		int i = p.second;
		if (Di[i] != p.first) continue;
		for (PT p2 : E[i]) {
			int j = p2.first;
			int cc = C[p2.second];
			int dd = C[p2.second];
			ll d = Di[i] + cc;
			if (Di[j] > d) {
				Di[j] = d;
				mae[j] = { i, p2.second };
				que.push(mp(d, j));
			}
		}
	}

	int tmp = N;
	while (mae[tmp].first) {
		C[mae[tmp].second] = D[mae[tmp].second];
		tmp = mae[tmp].first;
	}
	ll are = Di[N];

	rep1(i, N) Di[i] = 1e18;
	Di[1] = 0;
	que.push(mp(0, 1));
	while (que.size()) {
		PT p = que.top();
		que.pop();
		int i = p.second;
		if (Di[i] != p.first) continue;
		for (PT p2 : E[i]) {
			int j = p2.first;
			int cc = C[p2.second];
			int dd = C[p2.second];
			ll d = Di[i] + cc;
			if (Di[j] > d) {
				Di[j] = d;
				mae[j] = { i, p2.second };
				que.push(mp(d, j));
			}
		}
	}

	co(are + Di[N]);

	Would you please return 0;
}
0