poj3207 Ikki's Story IV - Panda's Trick
来源:互联网 发布:iphone4 ios7.1.2优化 编辑:程序博客网 时间:2024/05/20 10:20
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
”.
题解:
这一题的主要就是建图(2-SAT),我想先把把每条边都抽象成一个点a,再把a点拆成两个点,分别为a0和a1,分别表示这条边从内部连何从外部连。
代码(一部分):
function check(i,j:longint):boolean;
begin
if(x[j]>x[i])and(x[j]<y[i])and((y[j]<x[i])or(y[j]>y[i]))then exit(true);
if (y[j]>x[i])and(y[j]<y[i])and((x[j]<x[i])or(x[j]>y[i]))then exit(true);
check:=false;
end;
procedureadd(x,y:longint);
begin
inc(e);
side[e].x:=x;
side[e].y:=y;
side[e].next:=last[x];
last[x]:=e;
end;
procedure init;
var i,j:longint;
begin
readln(n,m);
for i:=1to m do
begin
readln(x[i],y[i]);
if x[i]>y[i]then
begin
x[i]:=x[i] xor y[i];
y[i]:=x[i] xor y[i];
x[i]:=x[i] xor y[i];
end;
end;
for i:=1to m-1 do
for j:=i+1 to m do
if check(i,j)then
begin
add(i,j+m);
add(i+m,j);
add(j,i+m);
add(j+m,i);
end;
end;
- POJ3207——Ikki's Story IV - Panda's Trick
- 【POJ3207】Ikki's Story IV - Panda's Trick【2-SAT】
- poj3207 Ikki's Story IV - Panda's Trick
- POJ3207 Ikki's Story IV - Panda's Trick
- poj3207 Ikki's Story IV - Panda's Trick
- poj3207 Ikki's Story IV - Panda's Trick(2-sat)
- Ikki's Story IV - Panda's Trick
- POJ3207-Ikki's Story IV - Panda's Trick(2-SAT)
- POJ3207.Ikki's Story IV - Panda's Trick——2-sat可行性判断
- Ikki's Story IV - Panda's Trick poj3207 tarjan+2-SAT
- poj3207 --Ikki's Story IV - Panda's Trick--强连通分量 & 2-sat & 判断可行性
- [POJ3207]Ikki's Story IV - Panda's Trick(2-SAT)
- 【POJ3207】Ikki's Story IV
- 【POJ3207】Ikki's Story IV
- poj3207-Ikki's Story IV
- POJ 3207 Ikki's Story IV-Panda's Trick
- poj 3207 Ikki's Story IV - Panda's Trick
- Pku 3207 Ikki's Story IV - Panda's Trick
- 山东省第七届ACM省赛------Julyed
- Android apk打包过程
- 滚动条样式的设定(ipad也好用)
- POJ 2524 Ubiquitous Religions (简单并查集,三种方式)
- leetcode-328. Odd Even Linked List
- poj3207 Ikki's Story IV - Panda's Trick
- hdu 1452(因子和+积性函数)
- [6-7]考试总结
- Android屏幕适配
- 使用GCC和Eclipse在Mac OS X下搭建nRF5系列BLE芯片开发环境
- 数书九章 内容
- ISCC2016 BASE 第二题好长的字符串
- java多线程与内存可见性
- Android签名与风险分析