Problem
Ikki’s Story IV - Panda’s Trick
Description
liympanda, one of Ikki’s friend, likes playing games with Ikki. Today after minesweeping with Ikki and winning so many times, he is tired of such easy games and wants to play another game with Ikki.
liympanda has a magic circle and he puts it on a plane, there are n points on its boundary in circular border: . Evil panda claims that he is connecting m pairs of points. To connect two points, liympanda either places the link entirely inside the circle or entirely outside the circle. Now liympanda tells Ikki no two links touch inside/outside the circle, except on the boundary. He wants Ikki to figure out whether this is possible…
Despaired at the minesweeping game just played, Ikki is totally at a loss, so he decides to write a program to help him.
Input
The input contains exactly one test case.
In the test case there will be a line consisting of of two integers: and . The following lines each contain two integers and , which denote the endpoints of the wire. Every point will have at most one link.
Output
Output a line, either “panda is telling the truth…” or “the evil panda is lying again”.
Sample Input
1 | 4 2 |
Sample Output
1 | panda is telling the truth... |
标签:2-SAT
Translation
个数排成一圈,给出若干条两点间的线段,可以在圈内连,也可在圈外连,问能否使得无相交线段(端点相交不算)
Solution
本题是的判定裸题。
把每条线段拆成两个点,即第条为和,分别代表在圈内和在圈外。若线段和相交,则连边,,这样跑一个再判断和是否在一个联通块内即可判断是否有冲突。
Code
1 |
|