Submission #76851999


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int i=a;i<n;i++)
typedef long long ll;
typedef pair<ll,int> pli;
const int N=2e5+5;
const ll INF=4e18;
int n,m;
ll Y;
vector<pli> g[N];
ll dist[N];
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cin>>n>>m>>Y;
rep(i,0,m){
int u,v; ll t;
cin>>u>>v>>t;
g[u].push_back({t,v});
g[v].push_back({t,u});
}
rep(i,1,n+1){
ll x; cin>>x;
g[i].push_back({x,0});
g[0].push_back({x+Y,i});
}
rep(i,0,n+1) dist[i]=INF;
priority_queue<pli,vector<pli>,greater<pli>> pq;
dist[1]=0;
pq.push({0,1});
while(!pq.empty()){
auto[d,u]=pq.top(); pq.pop();
if(d>dist[u]) continue;
for(auto[w,v]:g[u]){
if(dist[u]+w<dist[v]){
dist[v]=dist[u]+w;
pq.push({dist[v],v});
}
}
}
rep(k,2,n+1){
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int i=a;i<n;i++)
typedef long long ll;
typedef pair<ll,int> pli;
const int N=2e5+5;
const ll INF=4e18;
int n,m;
ll Y;
vector<pli> g[N];
ll dist[N];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>m>>Y;
    rep(i,0,m){
        int u,v; ll t;
        cin>>u>>v>>t;
        g[u].push_back({t,v});
        g[v].push_back({t,u});
    }
    rep(i,1,n+1){
        ll x; cin>>x;
        g[i].push_back({x,0});
        g[0].push_back({x+Y,i});
    }
    rep(i,0,n+1) dist[i]=INF;
    priority_queue<pli,vector<pli>,greater<pli>> pq;
    dist[1]=0;
    pq.push({0,1});
    while(!pq.empty()){
        auto[d,u]=pq.top(); pq.pop();
        if(d>dist[u]) continue;
        for(auto[w,v]:g[u]){
            if(dist[u]+w<dist[v]){
                dist[v]=dist[u]+w;
                pq.push({dist[v],v});
            }
        }
    }
    rep(k,2,n+1){
        cout<<dist[k];
        if(k<n) cout<<' ';
    }
    cout<<"\n";
    return 0;
}

Submission Info

Submission Time
Task E - Roads and Gates
User AllFinmyhand1
Language C++23 (GCC 15.2.0)
Score 450
Code Size 1065 Byte
Status AC
Exec Time 144 ms
Memory 36700 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 450 / 450
Status
AC × 3
AC × 29
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt, 01_random_24.txt, 01_random_25.txt, 01_random_26.txt, 01_random_27.txt, 01_random_28.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 2 ms 3528 KiB
00_sample_01.txt AC 1 ms 3528 KiB
00_sample_02.txt AC 1 ms 3456 KiB
01_random_03.txt AC 116 ms 34164 KiB
01_random_04.txt AC 118 ms 34124 KiB
01_random_05.txt AC 117 ms 34264 KiB
01_random_06.txt AC 117 ms 34160 KiB
01_random_07.txt AC 116 ms 34164 KiB
01_random_08.txt AC 116 ms 34200 KiB
01_random_09.txt AC 118 ms 34276 KiB
01_random_10.txt AC 116 ms 34216 KiB
01_random_11.txt AC 124 ms 34116 KiB
01_random_12.txt AC 124 ms 34124 KiB
01_random_13.txt AC 126 ms 34072 KiB
01_random_14.txt AC 106 ms 31864 KiB
01_random_15.txt AC 85 ms 29972 KiB
01_random_16.txt AC 64 ms 30068 KiB
01_random_17.txt AC 133 ms 34240 KiB
01_random_18.txt AC 144 ms 36504 KiB
01_random_19.txt AC 133 ms 36500 KiB
01_random_20.txt AC 13 ms 6560 KiB
01_random_21.txt AC 75 ms 21476 KiB
01_random_22.txt AC 38 ms 25188 KiB
01_random_23.txt AC 103 ms 30708 KiB
01_random_24.txt AC 102 ms 30664 KiB
01_random_25.txt AC 133 ms 36700 KiB
01_random_26.txt AC 133 ms 36652 KiB
01_random_27.txt AC 104 ms 29184 KiB
01_random_28.txt AC 107 ms 29168 KiB


2026-06-29 (Mon)
01:29:46 +09:00