Colored Sticks
Time Limit: 5000MS | Memory Limit: 128000K | |
Total Submissions: 27134 | Accepted: 7186 |
Description
You are given a bunch of wooden sticks. Each endpoint of each stick is colored with some color. Is it possible to align the sticks in a straight line such that the colors of the endpoints that touch are of the same color?
Input
Input is a sequence of lines, each line contains two words, separated by spaces, giving the colors of the endpoints of one stick. A word is a sequence of lowercase letters no longer than 10 characters. There is no more than 250000 sticks.
Output
If the sticks can be aligned in the desired way, output a single line saying Possible, otherwise output Impossible.
Sample Input
blue redred violetcyan blueblue magentamagenta cyan
Sample Output
Possible
Hint
Huge input,scanf is recommended.
Source
题意: 有很多个火彩 每头都有颜色 相同的颜色可以和另外的火柴相接 问这些火柴能不能连接成一条线
思路: 很明显这是一个欧拉通路问题 一笔画画完整个通路
用字典树标记字符串对应的id
用map超时
#include#include #include #include