Description
Liympanda, one of Ikki ' s friend, likes playing games with Ikki. Today after minesweeping with Ikki and winning so many times, he's tired of such easy games and wants to play another GAM E with Ikki.
Liympanda have a magic circle and he puts it on a plane, there is N points on its boundary in circular border:0, 1, 2, ..., n −1. Evil Panda claims that he is connecting m pairs of points. To connect points, Liympanda either places the link entirely inside the circle or entirely outside the circle. Now Liympanda tells Ikki no-links Touch inside/outside the circle, except on the boundary. He wants Ikki to figure out whether the is possible ...
Despaired at the minesweeping game just played, Ikki are 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 would be a line consisting of of of of the integers: n and m (n ≤1,000, m< /c3>≤500). The following m lines each contain integers ai and bi, which denote the endpoints of the ith wire. Every point would have the most one link.
Output
Output a line, either " panda is telling the truth...
" or " the evil panda is lying again
.
Sample Input
4 20 13 2
Sample Output
panda is telling the truth ... The first question of the
2-sat ... It's mostly written with a sense of feeling
#include <cstdio> #include <iostream>using namespace std; #define LL long long#define N 101000#define M 510000inline ll Read () {ll x=0,f=1;char Ch=getchar (); while (ch< ' 0 ' | | Ch> ' 9 ') {if (ch== '-') F=-1;ch=getchar ();} while (ch>= ' 0 ' &&ch<= ' 9 ') {x=x*10+ch-' 0 '; Ch=getchar ();} return x*f;} struct Edge{int to,next;} E[2*m];int n,m,cnt,cnt3,tt;int head[n];int a[n],b[n],inset[n];int dfn[n],low[n],belong[n];int top,zhan[N];inline void ins (int u,int v) {e[++cnt].to=v;e[cnt].next=head[u];head[u]=cnt;} inline void Insert (int u,int v) {ins (u,v); ins (v,u);} inline void dfs (int x) {zhan[++top]=x;inset[x]=1;dfn[x]=low[x]=++tt;for (int i=head[x];i;i=e[i].next) {if (!dfn[e[i]. To] {DFS (e[i].to); Low[x]=min (low[x],low[e[i].to]);} else if (inset[e[i].to]) {low[x]=min (low[x],dfn[e[i].to]);}} if (Dfn[x]==low[x]) {cnt3++;int p=-1;while (p!=x) {p=zhan[top--];belong[p]=cnt3;inset[p]=0;}}} inline void Tarjan () {for (int i=1;i<=2*m;i++) if (!dfn[i]) DFS (i);} inline bool Jud () {for (int i=1;i<=m;i++)if (Belong[2*i]==belong[2*i-1]) return 0;return 1;} inline void Buildmap () {for (Int. i=1;i<=m;i++) for (int j=i+1;j<=m;j++) if (A[i]<a[j]&&a[j]<b[i] &&b[j]>b[i]) | | (A[j]<a[i]&&a[i]<b[j]&&b[i]>b[j])) {Insert (2*I-1,2*J); insert (2*j-1,2*i);}} int main () {n=read (); M=read (); for (int i=1;i<=m;i++) {a[i]=read (); B[i]=read (); if (A[i]>b[i]) swap (a[i],b[i]);} Buildmap (); Tarjan (); if (Jud ()) printf ("Panda is telling the truth...\n"), Else printf ("The Evil Panda is lying again\n"); re Turn 0;}
poj3207 Ikki ' s story Iv-panda ' s Trick