#P7677. [COCI 2013/2014 #5] LADICE
[COCI 2013/2014 #5] LADICE
Description
There are items and drawers. Each drawer can hold only item. Each item can be placed into drawer or .
The rules for placing an item are as follows (performed in order: once condition is satisfied, execute it immediately and do not execute condition ; only if condition is not satisfied do you check condition , and so on):
-
If drawer is empty, put this item into drawer .
-
If drawer is empty, put this item into drawer .
-
Move the item currently in drawer to its other drawer. If that drawer is also full, move the item in that drawer to its other drawer, and so on, until you succeed or return to a drawer you have encountered before. If you succeed, put this item into that drawer.
-
Move the item currently in drawer to its other drawer. If that drawer is also full, move the item in that drawer to its other drawer, and so on, until you succeed or return to a drawer you have encountered before. If you succeed, put this item into that drawer.
-
Throw away this item.
For each given item, determine which items will be kept and which will be thrown away.
Input Format
The first line contains two integers and , representing the number of items and the number of drawers.
The next lines each contain two integers and , meaning that item can be stored in these two drawers.
Output Format
Output lines, each containing one string.
If the item is successfully stored, output LADICA.
If the item is thrown away, output SMECE.
5 3
1 2
1 3
1 2
1 3
1 2
LADICA
LADICA
LADICA
SMECE
SMECE
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
Hint
[Sample Explanation #1]
Item is placed into drawer , item into drawer , item into drawer , and items and have nowhere to go.
[Sample Explanation #2]
Item is placed into drawer , item into drawer , item into drawer , item into drawer , item into drawer , item into drawer , and item into drawer .
Both drawers for item are full. Move item in drawer to drawer , move item in drawer to drawer , move item in drawer to drawer . Drawer is empty, so the insertion succeeds.
Both drawers for item are full. Move item in drawer to drawer , move item in drawer to drawer , move item in drawer to drawer , move item in drawer to drawer , move item in drawer to drawer . Drawer is empty, so the insertion succeeds.
[Constraints]
For of the testdata, .
For of the testdata, , .
[Notes]
The score of this problem follows the original COCI setting, with a full score of .
Translated from COCI2013_2014 CONTEST #5 T6 LADICE.
Translated by ChatGPT 5
京公网安备 11011102002149号