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

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

Boat Commuter

면접 대비

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

요약
카드별로 탑승과 하차 이벤트를 처리하며, 완료된 이동은 |i-j|를, 미완료나 같은 부두 이동은 100을 부과한다.
난이도

보통10점 중 4점

유형
시뮬레이션, 구현, 배열, 해시맵
정답자
아직 제출이 없습니다

문제

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 mm travel cards (known affectionally as "Retsyo"), which are numbered from 11 to mm. 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 ii and finished at the pier jj (i≠ji \ne j), then its cost is ∣i−j∣|i-j| 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 p_ip\_i and card number c_ic\_i 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 nn, the number of travel cards mm, and the number of events kk (2≤n≤502 \le n \le 50, 1≤m,k≤1051 \le m, k \le 10^5).
  • kk further lines, each describing tap events in chronological order.
    • The ii-th event is described by two integers p_ip\_i and c_ic\_i (1≤p_i≤n1 \le p\_i \le n, 1≤c_i≤m1 \le c\_i \le m).

출력

Output mm integers separated by spaces --- the ii-th integer giving the total charge to be applied to the ii-th card.

예제1

  1. 예제 1

    입력
    3 3 5
    1 1
    1 2
    1 2
    3 1
    2 3
    
    예상 출력
    2 100 100