Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int adj[102][102];
- const int inf=0x3f3f3f3f;
- void menor(int n){
- for(int k=1;k<=n;k++){
- for(int i=1;i<=n;i++){
- for(int j=1;j<=n;j++){
- adj[i][j] = min (adj[i][j], adj[i][k]+adj[k][j]);
- }
- }
- }
- }
- int main(){
- int n, e, t, m, a, b, tt, soma=0;
- memset(adj, inf, sizeof(adj));
- cin>>n>>e>>t>>m;
- for(int i=0; i<m;i++){
- cin>>a>>b>>tt;
- adj[a][b]=tt;
- }
- for(int i=0;i<=n;i++){
- adj[i][i]=0;
- }
- menor(n);
- for(int i=1;i<=n;i++){
- if(adj[i][e]<=t) soma++;
- }
- printf("%d\n", soma);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement