Boat Commuter
면접 대비시간 제한2초메모리 제한1024 MB
카드별로 탑승과 하차 이벤트를 처리하며, 완료된 이동은 |i-j|를, 미완료나 같은 부두 이동은 100을 부과한다.
문제
The Bulgarian city of Nodnol runs a boat service to ferry its residents between the trendy areas in which they live and the large metallic structures in which they work on the next recession.
TFN (Transport For Nodnol) has issued travel cards (known affectionally as "Retsyo"), which are numbered from to . Each pier has a card terminal at which passengers are required to tap "in" when starting the trip and to tap "out" when finishing it.
As there is only one card terminal on each pier, passengers use the same device to tap in and to tap out.
Trip cost depends on the distance travelled and is determined as follows:
- if the trip started at the pier and finished at the pier (), then its cost is pounds;
- if the trip started somewhere and was not finished with a tap out, then it costs \pounds100;
- if the trip started and finished in the same place, then it also costs \pounds100, as it is interpreted as an attempt to game the system.
You are given a sequence of tapping events --- for each you have the pier and card number recorded. You are to determine how much the transport authority should charge each of the cards
입력
- One line containing three integer numbers: the number of piers , the number of travel cards , and the number of events (, ).
- further lines, each describing tap events in chronological order.
- The -th event is described by two integers and (, ).
출력
Output integers separated by spaces --- the -th integer giving the total charge to be applied to the -th card.