cf/mirror

AquaMoon and Time Stop (easy version)

CF
1545E13500· legendary gm3s1024 MB⌨ stdin/stdout

Examples

Sample 1of 4
Input
2
1
1 2 1 2
2 3 2 3
Output
2
Sample 2of 4
Input
3
4
1 4 1 2
1 4 4 15
6 7 1 4
Output
8
Sample 3of 4
Input
4
3
1 5 1 1
4 10 1 4
1 2 3 13
1 10 7 19
Output
14
Sample 4of 4
Input
7
5
78 96 76 91
6 16 18 37
53 63 40 56
83 88 21 38
72 75 17 24
63 63 53 60
34 46 60 60
Output
20
1545E1.cpp
loading editor…
Ln 11·137 BGNU C++20 (64)