結果

問題 No.1545 [Cherry 2nd Tune N] Anthem
ユーザー Kanten4205Kanten4205
提出日時 2021-05-26 14:54:13
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 3,102 bytes
コンパイル時間 2,420 ms
コンパイル使用メモリ 184,812 KB
実行使用メモリ 800,644 KB
最終ジャッジ日時 2024-05-08 16:23:49
合計ジャッジ時間 27,439 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,752 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 111 ms
19,968 KB
testcase_05 AC 782 ms
36,224 KB
testcase_06 AC 239 ms
17,588 KB
testcase_07 AC 193 ms
20,608 KB
testcase_08 AC 444 ms
19,600 KB
testcase_09 AC 138 ms
9,012 KB
testcase_10 AC 131 ms
17,792 KB
testcase_11 AC 286 ms
20,616 KB
testcase_12 AC 560 ms
31,184 KB
testcase_13 AC 126 ms
13,440 KB
testcase_14 AC 108 ms
19,072 KB
testcase_15 AC 36 ms
6,912 KB
testcase_16 AC 165 ms
24,448 KB
testcase_17 AC 79 ms
6,016 KB
testcase_18 AC 628 ms
25,568 KB
testcase_19 AC 296 ms
18,436 KB
testcase_20 AC 101 ms
7,116 KB
testcase_21 AC 183 ms
31,744 KB
testcase_22 AC 187 ms
26,752 KB
testcase_23 AC 285 ms
13,728 KB
testcase_24 AC 22 ms
5,376 KB
testcase_25 AC 882 ms
52,904 KB
testcase_26 AC 4 ms
5,376 KB
testcase_27 AC 141 ms
16,192 KB
testcase_28 AC 322 ms
16,128 KB
testcase_29 AC 85 ms
9,888 KB
testcase_30 AC 316 ms
28,184 KB
testcase_31 AC 188 ms
16,128 KB
testcase_32 AC 8 ms
5,376 KB
testcase_33 AC 389 ms
16,132 KB
testcase_34 AC 220 ms
9,800 KB
testcase_35 AC 1,851 ms
102,392 KB
testcase_36 AC 2,164 ms
102,140 KB
testcase_37 AC 30 ms
6,680 KB
testcase_38 AC 610 ms
52,936 KB
testcase_39 AC 295 ms
15,800 KB
testcase_40 AC 86 ms
9,828 KB
testcase_41 AC 17 ms
5,376 KB
testcase_42 AC 84 ms
9,792 KB
testcase_43 AC 192 ms
16,228 KB
testcase_44 AC 4 ms
5,376 KB
testcase_45 AC 4 ms
6,016 KB
testcase_46 AC 10 ms
5,464 KB
testcase_47 MLE -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
testcase_60 -- -
testcase_61 -- -
testcase_62 -- -
testcase_63 -- -
testcase_64 -- -
testcase_65 -- -
testcase_66 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
const long long MOD1 = 1000000007;
const long long MOD2 = 998244353;
#define logn long
#define lnog long
#define lgon long
#define itn int
typedef pair<long long, long long> P;
const long logn INF = 1e18;
int main() {
	long long N, S, T, K; cin >> N >> S >> T >> K;
	vector<long long>X(N + 1);
	for (long long i = 1; i <= N; i++) {
		cin >> X[i];
	}
	long long M; cin >> M;
	vector<vector<P>>E(N + 1);
	for (long long i = 0; i < M; i++) {
		long long A, B, Y; cin >> A >> B >> Y;
		E[A].push_back({ B, Y });
	}
	vector<vector<long long>>DP(N + 1, vector<long long>(K + 1, INF));
	DP[S][1] = X[S];
	vector<vector<P>>Prev(N + 1, vector<P>(K + 1, { 0, 0 }));
	priority_queue<pair<P, long long>, vector<pair<P, long long>>, greater<pair<P, long long>>>Q;
	Q.push({ {S,1 }, 0});
	while (!Q.empty()) {
		pair<P, long long> R = Q.top(); Q.pop();
		long long x = R.first.first, k = R.first.second, d = R.second;
		if (DP[x][k] < d) continue;
		//if (x == T && k == K) break;
		long long L = min(K, k + 1);
		for (const P &a : E[x]) {
			long long y = a.first, m = a.second;
			if (DP[x][k] + m + X[y] < DP[y][L]) {
				DP[y][L] = DP[x][k] + m + X[y];
				Prev[y][L] = { x, k };
				Q.push({ {y, L}, DP[y][L] });
			}
		}
	}
	if (DP[T][K] >= INF) {
		cout << "Impossible" << endl;
		return 0;
	}
	long long x = T, k = K;
	vector<long long>Z;
	while (k > 0) {
		Z.push_back(x);
		P ans = Prev[x][k];
		x = ans.first; k = ans.second;
	}
	cout << "Possible" << endl << DP[T][K] << endl << Z.size() << endl;
	for (long long i = Z.size() - 1; i >= 0; i--) {
		if (i != Z.size() - 1) cout << ' ';
		cout << Z[i];
	}
	cout << endl;
}
0