문제
Farmer John's
The fence consists of
Each cow has a preferred starting and ending position for her daily walk, each being points somewhere along the fence (possibly at posts, possibly not). Each cow walks along the fence for her daily walks, starting from her starting position and ending at her ending position. There are two routes that the cow could take, given that the fence forms a closed loop. Since cows are somewhat lazy creatures, each cow will walk in the direction around the fence that is shorter (if there is a tie, the cow may choose either direction).
Determine the distance that each cow walks.
입력
The first line of input contains
출력
Write
부분문제
| 번호 | 점수 | 조건 |
|---|---|---|
| #1 | 40점 | |
| #2 | 60점 | 추가 제약 조건 없음 |
예제
5 4
0 0
2 0
2 2
0 2
0 0 0 2
0 2 1 0
2 1 0 2
1 0 1 2
1 2 1 0
2
3
3
4
4
The first cow can walk directly from
The second cow can walk from
The fourth cow has two possible routes with equal lengths: