結果

問題 No.3616 WK vs AT vs MT vs SP
コンテスト
ユーザー 👑 kmjp
提出日時 2026-08-08 20:35:42
言語 C++17
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 66 ms / 2,000 ms
+ 744µs
コード長 2,177 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,320 ms
コンパイル使用メモリ 223,216 KB
実行使用メモリ 44,104 KB
最終ジャッジ日時 2026-08-08 20:35:52
合計ジャッジ時間 5,160 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
サブタスク 配点 結果
サンプル 0 % AC * 1
小課題1 8 % AC * 9
小課題2 16 % AC * 5
小課題3 20 % AC * 10
小課題4 20 % AC * 15
小課題5 20 % AC * 15
小課題6 16 % AC * 36
合計 2.5 * 100% = 250 点
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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,R;
ll C,S;
vector<pair<int,ll>> E[303030][4];
ll X[303030],Y[303030],Z[303030];
ll dp[30303][3][2];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>R>>C;
	FOR(i,N) cin>>X[i];
	FOR(i,N) cin>>Y[i];
	FOR(i,N) cin>>Z[i];
	FOR(i,N) {
		cin>>S;
		E[i][3].push_back({N,S});
		E[N][3].push_back({i,S+C});
	}
	FOR(i,N+1) {
		FOR(x,3) FOR(y,2) dp[i][x][y]=1LL<<60;
	}
	FOR(i,R) {
		cin>>x>>y>>j>>k>>l;
		k=min(k,j);
		l=min(k,l);
		x--,y--;
		E[x][0].push_back({y,j});
		E[y][0].push_back({x,j});
		E[x][1].push_back({y,k});
		E[y][1].push_back({x,k});
		E[x][2].push_back({y,l});
		E[y][2].push_back({x,l});
	}
	dp[0][0][0]=0;
	priority_queue<pair<ll,int>> Q;
	Q.push({0,0});
	while(Q.size()) {
		ll co=-Q.top().first;
		int cur=Q.top().second/6;
		int l1=Q.top().second%6/2;
		int l2=Q.top().second%2;
		Q.pop();
		if(dp[cur][l1][l2]!=co) continue;
		if(cur==N-1) {
			cout<<co<<endl;
			return;
		}
		if(cur<N) {
			if(chmin(dp[cur][1][l2],co+X[cur])) Q.push({-dp[cur][1][l2],cur*6+1*2+l2});
			if(chmin(dp[cur][2][l2],co+Y[cur])) Q.push({-dp[cur][2][l2],cur*6+2*2+l2});
			if(chmin(dp[cur][l1][1],co+Z[cur])) Q.push({-dp[cur][l1][1],cur*6+l1*2+1});
		}
		
		FORR2(e,c,E[cur][l1]) if(chmin(dp[e][l1][l2],co+c)) Q.push({-dp[e][l1][l2],e*6+l1*2+l2});
		if(l2) {
			FORR2(e,c,E[cur][3]) if(chmin(dp[e][l1][l2],co+c)) Q.push({-dp[e][l1][l2],e*6+l1*2+l2});
		}
		
	}
	
	
}


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