結果
| 問題 | No.3712 Urban Train |
| コンテスト | |
| ユーザー |
yaaya
|
| 提出日時 | 2026-09-11 22:51:24 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
WA
不安定
|
| 実行時間 | - |
| コード長 | 2,313 bytes |
| 記録 | |
| コンパイル時間 | 2,288 ms |
| コンパイル使用メモリ | 346,072 KB |
| 実行使用メモリ | 20,432 KB |
| 最終ジャッジ日時 | 2026-09-11 22:51:36 |
| 合計ジャッジ時間 | 6,749 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 35 WA * 4 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a-1;i>=b;i--)
#define ll long long
#define ull unsigned ll
#define ld long double
#define bl __int128_t
#define fi first
#define se second
#define vel vector<ll>
#define vvel vector<vel>
#define pll pair<ll,ll>
#define vepll vector<pll>
#define vvepll vector<vepll>
#define ves vector<string>
#define vem vector<mint>
#define vvem vector<vem>
#define pmm pair<mint,mint>
#define cleout(i) cout<<fixed<<setprecision(i)
template<class T>using PQ=priority_queue<T,vector<T>,greater<T>>;
// 上 右 下 左
vector<int> di={-1, 0, 1, 0};
vector<int> dj={ 0, 1, 0,-1};
vector<int> dx={ 0, 1, 0,-1};
vector<int> dy={ 1, 0,-1, 0};
vector<int> ddx={ 1, 1, 1, 0, -1, -1, -1, 0 };
vector<int> ddy={ 1, 0, -1, -1, -1, 0, 1, 1 };
ll inf=1000000000000000000;//1e18
// LLONG_MAX
mt19937_64 rng((ull)chrono::steady_clock::now().time_since_epoch().count());
void _solve(){
ll N,M;
cin>>N>>M;
vvepll G(N);
rep(i,0,M){
ll x,y,z;
cin>>x>>y>>z;
x--;
y--;
G[x].push_back({z,y});
G[y].push_back({z,x});
}
vel a(N),b(N),c(N);
rep(i,0,N)cin>>a[i];
rep(i,0,N)cin>>b[i];
rep(i,0,N)cin>>c[i];
vel ans(N,inf);
PQ<pll> pq;
ans[0]=1;
pq.push({1,0});
while(pq.size()){
ll now=pq.top().se;
pq.pop();
for(auto [C,y]:G[now]){
auto find=[&](ll x,ll y){
return (x+y-1)/y*y;
};
ll t=find(ans[now],a[now]);
if(t/a[now]%b[now]==0){
t+=c[now];
}
t+=C;
if(ans[y]>t){
ans[y]=t;
pq.push({ans[y],y});
}
t=find(ans[now],a[now]);
if(t/a[now]%b[now]==0){
t+=a[now]+C+c[now];
}else{
t=find(t,a[now]*b[now])+c[now]+C;
}
if(ans[y]>t){
ans[y]=t;
pq.push({ans[y],y});
}
}
}
cout<<ans.back()<<"\n";
}
int main(){
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
ll _;
bool multitest=0;
if(multitest)cin>>_;
else _=1;
rep(__,0,_){
_solve();
}
}
yaaya