結果

問題 No.1545 [Cherry 2nd Tune N] Anthem
ユーザー Kanten4205Kanten4205
提出日時 2021-05-19 19:20:48
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 3,099 bytes
コンパイル時間 2,320 ms
コンパイル使用メモリ 185,484 KB
実行使用メモリ 103,936 KB
最終ジャッジ日時 2024-05-08 16:20:50
合計ジャッジ時間 19,731 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,752 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 WA -
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 109 ms
19,968 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 191 ms
20,480 KB
testcase_08 WA -
testcase_09 AC 130 ms
9,148 KB
testcase_10 AC 127 ms
17,792 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 81 ms
5,888 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 177 ms
31,616 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 295 ms
28,180 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 AC 4 ms
5,376 KB
testcase_45 AC 4 ms
6,016 KB
testcase_46 AC 6 ms
5,464 KB
testcase_47 WA -
testcase_48 TLE -
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 + 1, K);
		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