# 题目大意：

$n\le 1,000,m\le 500$$n ≤ 1,000, m ≤ 500$

# 分析：

$i->{j}^{\prime }$$i->j'$
$j->{i}^{\prime }$$j->i'$
${i}^{\prime }->j$$i'->j$
${j}^{\prime }->i$$j'->i$

# 代码：

#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<stack>
#define N 1000005
#define M 505

using namespace std;

struct Edge{
int u, v, next;
}a[N];

int Ls[N], instack[N], dfn[N], low[N], belong[N], px[M], py[M];
int n, m, tot, num, cnt;

void addedge(int u, int v){
++tot;
a[tot].u = u; a[tot].v = v;
a[tot].next = Ls[u];  Ls[u]=tot;
}

stack <int>st;

void tarjan(int u) {
dfn[u] = low[u] = ++num;
instack[u] = 1;
st.push(u);
for (int i = Ls[u]; i; i = a[i].next) {
int v = a[i].v;
if (!dfn[v]){
tarjan(v);
low[u] = min(low[u], low[v]);
}
else if (instack[v]) low[u] = min(low[u], dfn[v]);
}

if (low[u] == dfn[u]) {
cnt++;
int rp;
while ("rp++") {
rp = st.top();
st.pop();
instack[rp] = 0;
belong[rp] = cnt;
if (rp == u) break;
}
}
}

void solve_problem() {
num = cnt = 0;
for (int i = 1; i <= 2 * m; i++)
instack[i] = belong[i] = dfn[i] = low[i] = 0;
for (int i = 1; i <= 2 * m; i++)
if (!dfn[i]) tarjan(i);
}

int main(){
while(~scanf("%d %d", &n, &m)){
for (int i = 1; i <= m; i++) {
scanf("%d %d", &px[i], &py[i]);
if (px[i] > py[i]) swap(px[i], py[i]);
}
for (int i = 1; i <= 2 * m; i++) Ls[i] = 0;
tot = 0;
for (int i = 1; i <= m; i++) {
for (int j = i + 1; j <= m; j++)
if (px[j] >= px[i] && px[j] <= py[i] && py[j] >= py[i] ||
py[j] >= px[i] && py[j] <= py[i] && px[j] <= px[i]) {
addedge(i, j + m);
addedge(j, i + m);
addedge(i + m, j);
addedge(j + m, i);
}
}
solve_problem();
bool check = 1;
for (int i = 1; i <= m; i++)
if (belong[i] == belong[i+m]) check = 0;
if (check) printf("panda is telling the truth...\n");
else printf("the evil panda is lying again\n");
}
return 0;
}  

• 广告
• 抄袭
• 版权
• 政治
• 色情
• 无意义
• 其他

120