比赛 |
NOIP2008集训模拟4 |
评测结果 |
AWWAWAWWAW |
题目名称 |
彩色穿孔卡片 |
最终得分 |
40 |
用户昵称 |
cuixiaofei |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2008-11-13 10:49:52 |
显示代码纯文本
//na :cuixiaofei;
//da :08_11_13;
program punch;
type
sss =record
z,y:longint;
end;
var
n,zge,fge :longint;
a :array[1..10000,1..2] of longint;
f :array[1..10000] of sss;
f1,f2 :text;
procedure swap(var x,y:longint);
var
t :longint;
begin
t:=x;
x:=y;
y:=t;
end;
procedure init;
var
i :longint;
begin
assign(f1,'punch.in');
reset(f1);
assign(f2,'punch.out');
rewrite(f2);
readln(f1,n);
fge:=0;
zge:=0;
for i:=1 to n do
begin
readln(f1,a[i,1],a[i,2]);
if a[i,1]>a[i,2] then
swap(a[i,1],a[i,2]);
end;
end;
procedure zhenghe(k:longint);
var
i :longint;
begin
for i:=1 to k-1 do
begin
if f[i].y>f[k].z then
begin
f[i].y:=f[k].y;
f[k].z:=f[i].z;
end
else if f[i].z<f[k].y then
begin
f[i].z:=f[k].z;
f[k].y:=f[i].y;
end;
end;
end;
procedure chakan(k:longint);
var
i :longint;
begin
for i:=1 to fge do
if (a[k,1]>f[i].z) and (a[k,2]<f[i].y) then
exit;
for i:=1 to fge do
begin
if (a[k,1]<f[i].z) and (a[k,2]>f[i].z) and (a[k,2]<f[i].y) then
begin
inc(zge);
f[i].z:=a[k,1];
zhenghe(i);
exit;
end
else if (a[k,1]>f[i].z) and (a[k,1]<f[i].y) and (a[k,2]>f[i].y) then
begin
inc(zge);
f[i].y:=a[k,2];
zhenghe(i);
exit;
end
else if (a[i,1]<f[i].z) and (a[i,2]>f[i].y) then
begin
f[i].z:=a[i,1];
f[i].y:=a[i,2];
zhenghe(i);
inc(zge);
exit;
end;
end;
inc(fge);
inc(zge);
f[fge].z:=a[k,1];
f[fge].y:=a[k,2];
end;
procedure main;
var
i,j :longint;
begin
for i:=n downto 1 do
begin
chakan(i);
end;
end;
procedure print;
begin
writeln(f2,zge);
close(f1);
close(f2);
end;
begin
init;
main;
print;
end.