Why-Salesman Tour
Time limit9sMemory limit256 MB
Decide whether a metric graph with up to 14 vertices has a Hamiltonian cycle of total length exactly L.
- Level
Medium7 of 10
- Topics
- Dynamic programming, Bit manipulation, Graph
- Solved
- No attempts yet
Problem
Hyunwoo has plenty of complaints about his job as a traveling salesman. He now calls himself a why-salesman instead.
The traveling salesman problem asks for the shortest route that visits every vertex of a graph once and returns to the start. The why-salesman problem has a different goal. In a graph with vertices, decide whether some route that visits every vertex once and returns to the start has length exactly . In other words, decide whether a cycle of size and length exists.
If , the tour that goes from one vertex to the other and back has length .
Input
The first line contains the number of vertices and the target distance . (, )
Each of the next lines gives the distances between vertices. The -th value on the -th line is the distance between vertex and vertex . If then , and for every . For all , and .
Output
Print possible on the first line if a cycle of size and length exists, and impossible otherwise. Print it without the quotation marks.