95652024-02-23 10:06:05hackemonHálózati átvitelcpp17Wrong answer 0/50284ms64252 KiB
#include <bits/stdc++.h>
#define pii pair<int, int>
using namespace std;

int n, m, k, h;
vector<vector<pii>> adj;
vector<int> mindist;
int main() {    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n >> m >> k >> h; 
    adj.resize(n + 1); 
    mindist.resize(n + 1, 0); 
    for(int i = 0;i < m;i++ ) { 
        int a, b, c;
        cin >> a >> b >> c; 
        adj[a].push_back({b, c});
    }
    queue<pii> pontok; 
    pontok.push({k, 0});
    mindist[k] = 0; 

    for(int i = 0;i < h;i++ ) { 
        int meret = pontok.size(); 
        for(int j = 0;j < meret;j++ ) { 
            auto f = pontok.front(); 
            pontok.pop(); 
            for(int z = 0;z < adj[f.first].size();z++ ) { 
                mindist[adj[f.first][z].first] = max(mindist[adj[f.first][z].first], adj[f.first][z].second);
                pontok.push({adj[f.first][z].first, mindist[adj[f.first][z].first]});
            }
        }
    }

    for(int i = 1;i <= n;i++ ) { 
        cout << mindist[i] << endl;
    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/50
1Accepted0/03ms2104 KiB
2Wrong answer0/04ms2932 KiB
3Wrong answer0/13ms2368 KiB
4Wrong answer0/13ms2504 KiB
5Wrong answer0/23ms2940 KiB
6Runtime error0/294ms64252 KiB
7Runtime error0/286ms64012 KiB
8Runtime error0/278ms63768 KiB
9Wrong answer0/14ms3508 KiB
10Wrong answer0/18ms4692 KiB
11Runtime error0/1115ms63328 KiB
12Runtime error0/192ms63132 KiB
13Runtime error0/2107ms62900 KiB
14Runtime error0/290ms62872 KiB
15Runtime error0/282ms62844 KiB
16Runtime error0/282ms62832 KiB
17Runtime error0/281ms62632 KiB
18Runtime error0/281ms62444 KiB
19Runtime error0/286ms62448 KiB
20Runtime error0/279ms62384 KiB
21Wrong answer0/127ms5268 KiB
22Wrong answer0/1105ms13852 KiB
23Runtime error0/1284ms62400 KiB
24Runtime error0/1228ms62408 KiB
25Runtime error0/2194ms62412 KiB
26Runtime error0/2199ms62400 KiB
27Runtime error0/2175ms62428 KiB
28Wrong answer0/234ms6052 KiB
29Wrong answer0/237ms6040 KiB
30Wrong answer0/235ms6028 KiB
31Wrong answer0/235ms6024 KiB
32Wrong answer0/235ms6196 KiB