记录编号 |
15501 |
评测结果 |
AAAAAA |
题目名称 |
[POI 1997] 阿里巴巴 |
最终得分 |
100 |
用户昵称 |
bing |
是否通过 |
通过 |
代码语言 |
Pascal |
运行时间 |
0.080 s |
提交时间 |
2009-11-13 15:32:22 |
内存使用 |
3.40 MiB |
显示代码纯文本
program bing;
type
jb=array[1..3] of integer;
var
f1,f2:text;
d,r:integer;
a0,a1:jb;
a:array[1..10,0..1] of jb;
b:array[0..150,0..150,0..150] of boolean;
procedure init;
begin
assign(f1,'ali.in');reset(F1);
assign(f2,'ali.out');rewrite(f2);
readln(f1,d);
end;
function pd(x,y:jb):boolean;
begin
if (x[1]>=y[1])and(x[2]>=y[2])and(x[3]>=y[3])then pd:=true
else pd:=false;
end;
function cl(x,y,z:jb):jb;
var
i:integer;
begin
for i:=1 to 3 do
cl[i]:=x[i]-y[i]+z[i];
end;
procedure nb;
var
i,k:integer;
h,t:longint;
m,s,v:jb;
f:boolean;
q:array[1..10000] of jb;
p:array[1..10000] of longint;
begin
fillchar(b,sizeof(b),true);
h:=1;t:=1;
b[a0[1],a0[2],a0[3]]:=false;
q[h]:=a0;
p[h]:=0;
repeat
for i:=1 to r do
begin
{ k:=0;
repeat
inc(k); }
k:=1;
v[1]:=k*a[i,0,1];v[2]:=k*a[i,0,2];v[3]:=k*a[i,0,3];
s[1]:=k*a[i,1,1];s[2]:=k*a[i,1,2];s[3]:=k*a[i,1,3];
f:=pd(q[h],v);
if f then
begin
m:=cl(q[h],v,s);
if b[m[1],m[2],m[3]] then
begin
inc(t);
q[t]:=m;
p[t]:=p[h]+1;
if pd(q[t],a1) then begin writeln(f2,p[t]);exit;end;
b[m[1],m[2],m[3]]:=false;
end;
end;
{until not f;}
end;
inc(h);
until h>t;
if h>t then writeln(f2,'NIE');
end;
procedure main;
var
i,j:integer;
begin
for i:=1 to d do
begin
readln(f1,a0[1],a0[2],a0[3]);
readln(f1,a1[1],a1[2],a1[3]);
readln(f1,r);
for j:=1 to r do
begin
read(f1,a[j,0,1],a[j,0,2],a[j,0,3]);
readln(f1,a[j,1,1],a[j,1,2],a[j,1,3]);
end;
nb;
end;
end;
begin
init;
main;
close(f1);close(f2);
end.