아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Fikapaus

시간 제한2초메모리 제한1024 MB

요약
두 사람의 시간별 위치 일정이 주어질 때, 정거장 사이를 직선으로 이동한다고 가정하고 두 사람이 가장 가까워지는 최초의 시각을 분 단위로 구한다.
난이도

보통10점 중 4점

유형
기하, 시뮬레이션
정답자
아직 제출이 없습니다

문제

In many cultures, the work day is punctuated by breaks. These breaks can improve productivity by allowing workers to relax. Some people like to drink water, some drink coffee, while others like to have a snack, read a book, take a walk, or talk to other people. In Sweden, the coffee break is popular and is called a “fikapaus.”

Imagine that you work in Sweden and you want to take one fikapaus each day with your coworker. Your work requires both of you to travel independently around your city throughout the day. Because the travel plans change daily, the best time to meet for a fikapaus differs on different days. But you do know your travel schedules in advance, and you can plan on meeting when the two of you are closest together. Write a program that determines the best time for a fikapaus.

입력

Input consists of multiple test cases. Each test case describes the travel schedules for you and your coworker for one day. The travel schedules start with an integer 1 ≤ D ≤ 20 indicating the number of destinations to which you and your coworker will each travel. Following this are D times and destination pairs, in the format of M X1 Y1 X2 Y2. The integer 0 ≤ M ≤ 500 represents the number of minutes after 9:00 AM when you will be at coordinates X1, Y1 in the city, and your coworker will be at coordinates X2, Y2 in the city. The coordinates are all integers in the range of 0 to 1000. For each test case the values for M are all unique and given in increasing order. The last test case is followed by a line containing a single zero.

출력

For each test case, print the case number (beginning with 1) followed by the time (in minutes after 9:00 AM) when you and your coworker will be closest to each other. Measure distance between points as the length of the straight line segment defined by the two points. If there are multiple times when the two of you will be closest, report the earliest time when you will be closest. Follow the format of the sample output.

예제1

  1. 예제 1

    입력
    4
    99 62 44 66 20
    199 14 36 67 92
    261 4 35 62 22
    359 15 31 11 55
    6
    0 21 32 31 6
    87 23 62 77 76
    134 59 25 56 81
    180 36 50 29 25
    288 69 9 83 16
    411 81 61 65 3
    0
    
    예상 출력
    Case 1: 99
    Case 2: 288