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

28367번 - Thieves and Prisons 서브태스크다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB1000.000%

문제

There are $n$ thieves and $k$ prisons. A thief is either on the run or caught in a prison. Initially all thieves are on the run.

A thief who is on the run can be caught by the police, and then ends up in one of the prisons. A thief who is on the run can also open the gate of a prison. Then every thief in that prison is released from the prison. It would be pointless to open the gate of an empty prison, so that never happens.

You are given a list of $m$ events of the form "thief $x$ has been caught" or "thief $x$ has opened the gate of a prison". Your task is to find a prison assignment that corresponds to the events, or determine that it is not possible.

입력

The first input line has three integers $n,ドル $k$ and $m$: the number of thieves, prisons and events. The thieves and prisons are numbered 1,2,ドル\dots,n$ and 1,2,ドル\dots,k$.

After this, there are $m$ lines that describe the events. Each event is "C $x$" (thief $x$ has been caught) or "O $x$" (thief $x$ opens the gate of a prison).

출력

Print a valid prison assignment that consists of $m$ integers: for every event the corresponding prison. If there are no solutions, print "IMPOSSIBLE".

제한

서브태스크

번호배점제한
18

1ドル≤n,m≤10,ドル $k=2$

213

1ドル≤n,k,m≤10^5,ドル $n=k$

314

1ドル≤n,m≤10^5,ドル $k=2$

418

1ドル≤n,k,m≤500$

547

1ドル≤n,k,m≤10^5$

예제 입력 1

3 2 5
C 1
C 2
O 3
O 2
C 1

예제 출력 1

1 2 2 1 1

예제 입력 2

1 1 1
O 1

예제 출력 2

IMPOSSIBLE

힌트

출처

Olympiad > Nordic Olympiad in Informatics > NOI 2019 B번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

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

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