cf/mirror

Crossing the Railways

CF
1776E3500· legendary gm4s1024 MB⌨ stdin/stdout

Examples

Sample 1of 4
Input
4 3 5 1
1 2 1
3 4 1
2 3 2
3 4 3
Output
0
Sample 2of 4
Input
3 3 12 2
2 10 1
1 6 2
8 12 3
Output
2
Sample 3of 4
Input
8 4 13 2
1 4 1
5 13 1
1 5 2
6 13 2
1 9 3
10 13 3
1 10 4
11 13 4
Output
2
Sample 4of 4
Input
1 1 2 2
1 2 1
Output
-1
1776E.cpp
loading editor…
Ln 11·137 BGNU C++20 (64)