RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
COCI00298

Ladice

Unrated 레이팅 미적용
난이도
1s
시간 제한
32MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

\(5^{th}\) round, February \(15^{th}\), 2014
Authors: Luka Kalinovčić, Gustav Matula

Mirko has N items (labeled with numbers from 1 to N) and L drawers (labeled with numbers from 1 to
L). All items are currently scattered throughout his room, so he decided to clean them up. Each drawer
can contain one item, and in order to make it easier for Mirko to find them later, he has determined in
advance exactly two drawers (A_{i} and B_{i}) for each item i.

Mirko stores the items in order from 1 to N using the first rule he can apply:
1. If the drawer A_{i} is empty, he stores the item i in that drawer
2. If the drawer B_{i} is empty, he stores the item i in that drawer
3. Try to move the item from A_{i} to its other drawer; if that one's filled too, try moving that item to
its other drawer, and so on until you either succeed or get back to a previously seen drawer. In
case of success, store the item i in the drawer A_{i}. In case of failure, continue to next rule.
4. Try moving the item from B_{i} to its other drawer; if that one's filled too, try moving that item to
its other drawer, and so on until you either succeed or get back to a previously seen drawer. In
case of success, store the item i in the drawer B_{i}. In case of failure, continue to next rule.
5. Give up and throw away the item i.

For given pairs of drawers for each item, determine which items will be stored and which will be
thrown away.

제약

In test cases worth 50% of total points, both N and L will be lesser than 2000.

입력 형식

The first line of input consists of two integers, N and L (\(1 \le N\), \(L \le 300\,000\)), the number of items
and the number of drawers.
Each of the following N lines contains two integers: A_{i} and B_{i} (\(1 \le A_{i}\) and \(B_{i} \le L\)), pair of drawers
corresponding to the item i. The numbers A_{i} and B_{i} will be different.

출력 형식

For each item, respectively, output where it ends up.
In case the item is stored successfully, output "LADICA" (without quotes, Croatian word for drawer).
In case the item is thrown away, output "SMECE" (without quotes, Croatian word for trash).
\(5^{th}\) round, February \(15^{th}\), 2014
Authors: Luka Kalinovčić, Gustav Matula

예제 1
입력
5 3
1 2
1 3
1 2
1 3
1 2
출력
LADICA
LADICA
LADICA
SMECE
SMECE
예제 2
입력
9 10
1 2
3 4
5 6
7 8
9 10
2 3
1 5
8 2
7 9
출력
LADICA
LADICA
LADICA
LADICA
LADICA
LADICA
LADICA
LADICA
LADICA
설명

Clarification of the first example: The first item goes to drawer 1 by rule 1). The second item goes to
drawer 3 by rule 2). The third item goes to drawer 2 by rule 2).
For the fourth and fifth item, both drawers are already taken and cannot be emptied.
Clarification of the second example: The first six items go into drawers 1, 3, 5, 7, 9, 2 (respectively),
by rule 1). For the seventh item, applying the rule 3), we try to move the item in drawer 1 to drawer 2,
the item in drawer 2 to drawer 3, the item in drawer 3 to drawer 4, which we succeed because the
drawer is empty.
The eighth item goes to drawer 8 which was empty from the beginning.
For the ninth item, applying the rule 3), we try to move the item in drawer 7 to drawer 8, the item in
drawer 8 to drawer 2, the item in drawer 2 to drawer 1, the item in drawer 1 to drawer 5, the item in
drawer 5 to drawer 6, which we succeed because the drawer is empty.

문제 정보

생성자가 기록되지 않았습니다.

출처 COCI 2013/2014 Contest 5

평가 및 의견

Ladice

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Ladice

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8