#FW0000117. Những tuyến đường tổng thống có thể đi (President's Path)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Những tuyến đường tổng thống có thể đi (President's Path)
President's Path
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
There are cities connected by undirected positive-length roads, with at most one direct road per unordered pair. For every , the President can choose any shortest path from to . Count distinct original roads lying on at least one such shortest path, counting each road once even if multiple shortest paths use it. Use when is unreachable.
Input
First line , followed by lines . Cities are indexed from .
Output
Print integers in lexicographic pair order , separated by spaces.
Subtasks
-
Subtask 1 (40 points): , , . All input conditions remain in force.
-
Subtask 2 (60 points): , , . All input conditions remain in force.
Examples
Input
3 3
1 2 1
2 3 1
1 3 2
Output
1 3 1
Explanation
There is 1 eligible road for pair (1,2), 3 eligible roads for (1,3), and 1 for (2,3).