← 返回 snowflake 的题目列表Map Coloring Problem with Three Colors
类型:online_judge
Given a list of locations list_of_locations and a list of tuples representing the adjacencies adjacencies between these locations, determine if it's possible to color all locations using three colors (red, blue, green) such that adjacent locations have different colors. Return a boolean value True or False, or provide a specific coloring scheme.
Example Input:
n = 5 # Number of locations
list_of_locations = [1, 2, 3, 4, 5]
adjacencies = [(1, 2), (2, 3), (3, 4), (4, 5), (5, 1), (1, 3)]
Example Output:
True (or any valid coloring scheme such as [Red, Green, Blue, Red, Green])
Constraints:
There are at least two locations in list_of_locations.
All tuples in adjacencies reference valid locations.
Use exactly three colors (red, blue, green) for coloring.
Example
Input
5
1 2 3 4 5
1 2
2 3
3 4
4 5
5 1
1 3