Logo
(追記) (追記ここまで)

21917번 - Mistake 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 256 MB89524972.059%

문제

As an apprentice algorithms enthusiast, it is not a great surprise that Mike struggles to cope with overly complex systems. Unfortunately, this turned out to be a big problem in the company he is currently interning.

Mike’s assigned project involves tinkering with the company’s Intelligent Cluster for Parallel Computation. This is just a fancy name; in reality, the system is just a simple job scheduler, handling a total of $n$ jobs. Some jobs might depend on successful execution of other jobs before being able to be executed. There are $m$ such dependencies in total.

It is guaranteed that there are no (direct or indirect) circular dependencies between jobs.

When a run is started, the systems intelligently picks an order to execute these jobs so that all the dependencies are met (the order may change between different runs). After picking a valid ordering, it starts executing each of the $n$ jobs in that order. When the system starts executing a job, it prints the id of the job to a log file.

Unfortunately, today was Mike’s first day interning at the company and he wasn’t very cautious. Consequently, he accidentally ran the system $k$ times in parallel. The system started erratically launching jobs and printing to the log file. Now the log file contains $n \cdot k$ ids of all the jobs that were executed. The job ids from the same run have been printed in the order they were executed, but the outputs from different runs may appear interweaved arbitrarily.

Your task is to figure out which jobs were executed in each of the $k$ runs from the information inside the log file.

입력

The first line of the input will contain three integers $n,ドル $k,ドル $m$ (1ドル \le n, k \le 500,000円,ドル 0ドル \le m \le 250,000円,ドル $n \cdot k \le 500,000円$), the number of jobs in the system, the number of runs Mike had triggered, and the number of dependencies.

The following $m$ lines will contain a pair $a_i,ドル $b_i$ (1ドル \le a_i , b_i \le n,ドル $a_i \ne b_i,ドル for all 1ドル \le i \le m$) describing a dependency of kind: “job $a_i$ must be executed before job $b_i$”.

Finally, the last line of the input contains $n \cdot k$ integers $c_i$ (1ドル \le c_i \le n,ドル for all 1ドル \le i \le n \cdot k$), the job ids that have been printed in the log file, in order.

출력

Output a single line consisting of $n \cdot k$ integers $r_i$ (1ドル \le r_i \le k,ドル for all 1ドル \le i \le n \cdot k$), the run id corresponding to each of the jobs in the log file. More specifically, $r_i$ should be the run id corresponding to the $i$-th job, as it appears in the log file.

If multiple solutions are possible, any one is accepted. It is guaranteed that the input data is valid and that a solution always exists.

제한

예제 입력 1

3 3 2
1 2
1 3
1 1 2 3 3 2 1 2 3

예제 출력 1

1 2 2 1 2 1 3 3 3

힌트

출처

ICPC > Regionals > Europe > Southeastern European Regional Contest > SEERC 2020 M번

Contest > Open Cup > 2020/2021 Season > Stage 17: Grand Prix of Southern Europe M번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /