Given a weighted graph with n nodes and m edges. for each node v we should calculate number of nodes u such that d(v,u)<=k . n,m<=5e4 k<=100; Please somebody help me. UPD: I don't know if it's important or not but Wi<=100 for every edge.

# | User | Rating |
---|---|---|

1 | MiFaFaOvO | 3681 |

2 | Um_nik | 3544 |

3 | maroonrk | 3431 |

4 | tourist | 3409 |

5 | apiadu | 3397 |

6 | 300iq | 3317 |

7 | ecnerwala | 3260 |

7 | Benq | 3260 |

9 | LHiC | 3229 |

10 | TLE | 3223 |

# | User | Contrib. |
---|---|---|

1 | Errichto | 193 |

2 | antontrygubO_o | 191 |

3 | vovuh | 178 |

4 | pikmike | 177 |

5 | tourist | 166 |

6 | Um_nik | 165 |

7 | McDic | 164 |

8 | ko_osaga | 163 |

9 | Radewoosh | 162 |

10 | Geothermal | 157 |

Given a weighted graph with n nodes and m edges. for each node v we should calculate number of nodes u such that d(v,u)<=k . n,m<=5e4 k<=100; Please somebody help me. UPD: I don't know if it's important or not but Wi<=100 for every edge.

↑

↓

Codeforces (c) Copyright 2010-2020 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Jun/02/2020 02:23:38 (f3).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|

As

kis small here. You can do DP with states —DP(u,k) = number of nodes in subtree ofuat distancek. Then you need to combine answers for subtrees. ComplexityO(nk). (Notice that we are not interested in any path of length >k)However this problem can also be solved in

O(nlogn), for largek, using Centroid Decomposition.You can submit the unweighted graph version of this problem here — 161D - Distance in Tree.

Will this tree concept work for cyclic graph ? (Subtree)

The graph isn't a tree.

i have some problem in 161D

your comment help me a lot thx.

Auto comment: topic has been updated by EBAD (previous revision, new revision, compare).Are negative weights allowed?