首页 技术 正文
技术 2022年11月9日
0 收藏 354 点赞 2,918 浏览 2411 个字
Time Limit: 1000MS   Memory Limit: 131072K
Total Submissions: 9426   Accepted: 3465

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: 0, 1, 2, …, n − 1. 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: n and m (n ≤ 1,000, m ≤ 500). The following m lines each contain two integers ai and bi, which denote the endpoints of the ith 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

4 2
0 1
3 2

Sample Output

panda is telling the truth...

Source

POJ Monthly–2007.03.04, Ikki 又是WA在数组不够大← 连接两个点的一段线,要么全部在圆里,要么全部在圆外先在各段线之间连边:若是两段线可能有交叉,那么必须一个在圆里,一个在圆外建好图后用tarjan求强连通分量,若是表示一段线在圆里和圆外的两个点在同一个强连通分量里,那么就不可行

 #include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
const int mxn=;
//bas
int n,m;
int hd[mxn],cnt=;
int a[mxn],b[mxn]; //edge
struct edge{
int to;
int next;
}e[mxn];
void add_edge(int u,int v){
e[++cnt].next=hd[u];e[cnt].to=v;hd[u]=cnt;
} //tarjan
int vis[mxn];
int dfn[mxn],low[mxn];
int st[mxn],top;
bool inst[mxn];
int dtime=;
int belone[mxn],tot;
void tarjan(int s){
low[s]=dfn[s]=++dtime;
st[++top]=s;
inst[s]=;
for(int i=hd[s];i;i=e[i].next){
int v=e[i].to;
if(!dfn[v]){
tarjan(v);
low[s]=min(low[s],low[v]);
}
else if(inst[v]){
low[s]=min(low[s],dfn[v]);
}
}
int v;
if(low[s]==dfn[s]){
cnt++;
do{
v=st[top--];
inst[v]=;
belone[v]=cnt; }while(v!=s);
}
return;
} //
void Build(){
int i,j;
for(i=;i<m;i++)
for(j=i+;j<=m;j++){
if((a[i]<a[j] && a[j]<b[i] && b[i]<b[j]) ||
(a[i]>a[j] && a[i]<b[j] && b[i]>b[j]) ){
add_edge(i,j+m);//用+m的点表示在外面
add_edge(j,i+m);
add_edge(i+m,j);
add_edge(j+m,i); }
}
return;
}
int main(){
scanf("%d%d",&n,&m);
int i,j;
for(i=;i<=m;i++){
scanf("%d%d",&a[i],&b[i]);
a[i]++;b[i]++;
if(a[i]>b[i])swap(a[i],b[i]);
}
Build();
n=*m;
for(i=;i<=n;i++)if(!dfn[i])tarjan(i);
for(i=;i<=m;i++){
if(belone[i]==belone[i+m]){
printf("the evil panda is lying again");
return ;
}
}
printf("panda is telling the truth...");
return ;
}
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,489
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,904
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,737
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,490
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:8,128
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,291