DWITE Online Computer Programming Contest, November 2010, Problem 5
A cogwheel is a toothed wheel, ideal for connecting with other cogwheels and assembling machinery. A rotating cogwheel will spin all of the directly connected cogwheels in an opposite direction. However, too many cogwheels can lock up. For example, three cogwheels that are all connected will not be able to move, as some cogwheels will try to spin against each other.
The input will contain 5 test cases. The first line of a test case will contain two integers
Assume that cog
The output will contain 5 lines, describing the directions of rotation of cogs identified by A
for clockwise, B
for counter-clockwise, and L
if a cog is locked. For example, if cog AB
. If both are locked, then the output is LL
.
Note: there will always be at least cogs
Sample Input
3 3
1 2
2 3
3 1
4 4
1 2
2 3
3 4
4 1
Sample Output
LL
BA
Problem Resource: DWITE
Comments