1218 -> Why WA after 0.37 sec using 87K ?? Any ideas ? Thanks!
I really have no idea what might be wrong :(
const
MaxJ=501;
var
names:array[1..maxj]of string;
canwin:array[1..maxj]of boolean;
stats:array[1..maxj,1..3]of longint;
jedcount,killed:longint;
can:boolean;
procedure readdata;
var
name:string;
zn:char;
i:longint;
begin
readln(jedcount);
for i:=1 to jedcount do
begin
name:='';
read(zn);
while zn=' ' do
read(zn);
while zn<>' 'do
begin
name:=name+zn;
read(zn)
end;
names[i]:=name;
readln(stats[i,1],stats[i,2],stats[i,3])
end
end;
function canbekilled(i:longint):boolean;
var j:longint;
begin
inc(killed);
canbekilled:=false;
for j:=1 to jedcount do
if j<>i then
begin
if ((stats[i,1]>stats[j,1])and(stats[i,2]>stats[j,2]))or
((stats[i,3]>stats[j,3])and(stats[i,2]>stats[j,2]))or
((stats[i,1]>stats[j,1])and(stats[i,3]>stats[j,3]))
then
else canbekilled:=true;
end
end;
procedure solve;
var
i,j:longint;
begin
fillchar(canwin,sizeof(canwin),false);
for i:=1 to jedcount do
begin
can:=true;
killed:=0;
for j:=1 to jedcount do
if j<>i then
begin
if ((stats[i,1]>stats[j,1])and(stats[i,2]>stats[j,2]))or
((stats[i,3]>stats[j,3])and(stats[i,2]>stats[j,2]))or
((stats[i,1]>stats[j,1])and(stats[i,3]>stats[j,3]))or
canbekilled(j)
then
else can:=false
end;
if killed>1 then can:=false;
canwin[i]:=can
end
end;
procedure writeout;
var
i:longint;
begin
for i:=1 to jedcount do
if canwin[i]=true then
writeln(names[i])
end;
begin
readdata;
solve;
writeout
end.