46992023-03-31 09:38:52Erik_GepardHálózati átvitelcpp17Wrong answer 0/50651ms5552 KiB
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
 
int n, m, rajt, cel, h;
 
struct el{
  int a;
  int b;
  int suly;
};
 
el e1;
vector<el> e;
 
void bellman_ford(){
  vector<int> d(n+1, -1);
  d[rajt]=0;
  for(int i=0; i<n; i++){
    for(int j=0; j<m; j++){
      if(d[e[j].a]>-1){
        if(d[e[j].b]<e[j].suly){
          d[e[j].b]=e[j].suly;
        }
      }
    }
  }
  for(int i=1; i<=n; i++){
    if(d[i]<1e9){
        cout<<d[i]<<"\n";
    }
    else{
        cout<<"-1\n";
    }
  }
}
 
 
void solve() {
  cin>>n>>m>>rajt>>h;
  for(int i=0; i<m; i++){
    int x, y, z;
    cin>>x>>y>>z;
    e1.a=x;
    e1.b=y;
    e1.suly=z;
    e.push_back(e1);
  }
  bellman_ford();
}
 
int main() {
	ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  solve();
	return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/50
1Accepted0/03ms1824 KiB
2Wrong answer0/03ms2168 KiB
3Wrong answer0/13ms2236 KiB
4Wrong answer0/13ms2448 KiB
5Wrong answer0/23ms2668 KiB
6Wrong answer0/23ms2908 KiB
7Wrong answer0/23ms3000 KiB
8Wrong answer0/23ms3256 KiB
9Wrong answer0/14ms3212 KiB
10Wrong answer0/114ms3476 KiB
11Wrong answer0/110ms3692 KiB
12Wrong answer0/112ms3644 KiB
13Wrong answer0/210ms3728 KiB
14Wrong answer0/212ms4144 KiB
15Wrong answer0/219ms4300 KiB
16Wrong answer0/219ms4584 KiB
17Wrong answer0/219ms4536 KiB
18Wrong answer0/219ms4500 KiB
19Wrong answer0/219ms4500 KiB
20Wrong answer0/219ms4476 KiB
21Wrong answer0/1127ms4496 KiB
22Time limit exceeded0/1651ms3812 KiB
23Time limit exceeded0/1560ms3968 KiB
24Time limit exceeded0/1648ms4132 KiB
25Time limit exceeded0/2564ms3968 KiB
26Time limit exceeded0/2552ms3964 KiB
27Time limit exceeded0/2573ms4020 KiB
28Wrong answer0/2287ms5236 KiB
29Wrong answer0/2287ms5552 KiB
30Wrong answer0/2280ms5448 KiB
31Wrong answer0/2273ms5448 KiB
32Wrong answer0/2293ms5452 KiB