結果

問題 No.1545 [Cherry 2nd Tune N] Anthem
ユーザー 👑 kmjpkmjp
提出日時 2021-06-12 00:48:34
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,845 bytes
コンパイル時間 2,504 ms
コンパイル使用メモリ 212,212 KB
実行使用メモリ 172,048 KB
最終ジャッジ日時 2023-08-21 16:03:59
合計ジャッジ時間 26,074 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
42,488 KB
testcase_01 AC 15 ms
42,308 KB
testcase_02 WA -
testcase_03 AC 15 ms
42,320 KB
testcase_04 AC 219 ms
76,760 KB
testcase_05 AC 878 ms
172,048 KB
testcase_06 AC 262 ms
80,848 KB
testcase_07 AC 189 ms
67,064 KB
testcase_08 AC 1,102 ms
153,416 KB
testcase_09 AC 256 ms
73,712 KB
testcase_10 AC 71 ms
49,488 KB
testcase_11 AC 396 ms
101,960 KB
testcase_12 AC 674 ms
143,468 KB
testcase_13 AC 140 ms
62,844 KB
testcase_14 AC 234 ms
80,056 KB
testcase_15 AC 36 ms
45,196 KB
testcase_16 AC 337 ms
95,076 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 286 ms
84,744 KB
testcase_20 AC 240 ms
75,724 KB
testcase_21 AC 365 ms
102,368 KB
testcase_22 AC 177 ms
65,980 KB
testcase_23 AC 198 ms
66,732 KB
testcase_24 AC 38 ms
50,896 KB
testcase_25 AC 57 ms
56,124 KB
testcase_26 AC 15 ms
42,396 KB
testcase_27 AC 30 ms
46,928 KB
testcase_28 AC 87 ms
61,920 KB
testcase_29 AC 64 ms
57,784 KB
testcase_30 AC 50 ms
53,904 KB
testcase_31 AC 57 ms
54,816 KB
testcase_32 AC 30 ms
47,676 KB
testcase_33 AC 84 ms
60,940 KB
testcase_34 AC 62 ms
56,336 KB
testcase_35 AC 268 ms
102,360 KB
testcase_36 AC 199 ms
86,556 KB
testcase_37 AC 20 ms
44,616 KB
testcase_38 AC 95 ms
62,820 KB
testcase_39 AC 24 ms
45,316 KB
testcase_40 AC 34 ms
50,020 KB
testcase_41 AC 18 ms
43,596 KB
testcase_42 AC 52 ms
53,172 KB
testcase_43 AC 69 ms
56,780 KB
testcase_44 AC 19 ms
43,128 KB
testcase_45 AC 18 ms
45,084 KB
testcase_46 AC 44 ms
55,600 KB
testcase_47 AC 65 ms
63,280 KB
testcase_48 AC 68 ms
65,376 KB
testcase_49 AC 153 ms
83,260 KB
testcase_50 AC 252 ms
105,212 KB
testcase_51 AC 25 ms
45,660 KB
testcase_52 AC 469 ms
148,732 KB
testcase_53 AC 98 ms
74,760 KB
testcase_54 AC 33 ms
47,940 KB
testcase_55 AC 296 ms
114,668 KB
testcase_56 AC 18 ms
43,300 KB
testcase_57 AC 234 ms
98,276 KB
testcase_58 AC 143 ms
88,652 KB
testcase_59 AC 28 ms
47,476 KB
testcase_60 AC 27 ms
48,876 KB
testcase_61 AC 80 ms
60,456 KB
testcase_62 AC 224 ms
93,624 KB
testcase_63 AC 100 ms
65,828 KB
testcase_64 AC 621 ms
170,544 KB
testcase_65 AC 30 ms
46,376 KB
testcase_66 AC 259 ms
115,860 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------

int N,S,T,K,M;
int X[101010];
int A[101010],B[101010];
vector<vector<int>> E[1505050];
ll dp[2020202];
int from[2020202];
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>S>>T>>K;
	S--,T--;
	FOR(i,N) cin>>X[i];
	cin>>M;
	FOR(i,M) {
		cin>>x>>y>>k;
		x--,y--;
		FOR(j,K-1) {
			E[N*j+x].push_back({N*(j+1)+y,i,X[y]+k});
		}
		E[N*(K-1)+x].push_back({N*(K-1)+y,i,X[y]+k});
	}
	FOR(i,N*K) dp[i]=1LL<<60;
	priority_queue<pair<ll,int>> Q;
	dp[S]=X[S];
	Q.push({-X[S],S});
	while(Q.size()) {
		ll co=-Q.top().first;
		int cur=Q.top().second;
		Q.pop();
		if(dp[cur]!=co) continue;
		FORR(e,E[cur]) if(dp[e[0]]>co+e[2]) {
			dp[e[0]]=co+e[2];
			from[e[0]]=cur;
			Q.push({-dp[e[0]],e[0]});
		}
	}
	
	if(dp[N*(K-1)+T]==1LL<<60) {
		cout<<"Impossible"<<endl;
	}
	else {
		cout<<"Possible"<<endl;
		cout<<dp[N*(K-1)+T]<<endl;
		int cur=N*(K-1)+T;
		vector<int> V;
		while(cur>=N) {
			V.push_back(cur);
			cur=from[cur];
		}
		V.push_back(cur);
		reverse(ALL(V));
		cout<<V.size()<<endl;
		FORR(v,V) cout<<(v%N+1)<<" ";
		cout<<endl;
		
	}
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0