Letöltés: mp_menetrend.pas Program menetrend;
Type ido=record ora,perc:byte
End;
Type vonat=record indul,erkezik:ido;
End;
Var be,ki:text;
VA,VB:array[1..100] of vonat;
N,i,a,b,f,aa2,ab2:byte;
Function idok(s:string):vonat;
Var ora,perc:string;
Begin
ora:=s[1]+s[2];
perc:=s[4]+s[5];
val(ora,idok.indul.ora);
val(perc,idok.indul.perc);
ora:=s[7]+s[8];
perc:=s[10]+s[11];
val(ora,idok.erkezik.ora);
val(perc,idok.erkezik.perc);
End;
Procedure beolvas;
Var i:longint;
s:string;
Begin
readln(be,f);
readln(be,a,b);
for i:=1 to a do
Begin
readln(be,s);
va[i]:=idok(s);
End;
for i:=1 to b do
Begin
readln(be,s);
vb[i]:=idok(s);
End;
End;
Procedure csere(Var y:array of vonat;a,b:byte);
Var x:vonat;
Begin
x:=y[a];
y[a]:=y[b];
y[b]:=x;
End;
Function kisebb(a,b:vonat):boolean;
Begin
if a.indul.ora>b.indul.ora then kisebb:=true;
if a.indul.ora<b.indul.ora then kisebb:=false;
if (a.indul.ora=b.indul.ora) and (a.indul.perc>b.indul.perc) then kisebb:=true;
if (a.indul.ora=b.indul.ora) and (a.indul.perc<b.indul.perc) then kisebb:=false;
if (a.indul.ora=b.indul.ora) and (a.indul.perc=b.indul.perc) then kisebb:=false;
End;
Procedure rendez(a:array of vonat;b:byte);
Var i,j,hely:longint;
Begin
for i:=1 to b-1 do
Begin
hely:=i;
for j:=i+1 to b do
Begin
if kisebb(a[hely],a[j]) then
Begin
hely:=j;
End;
End;
csere(a,i,hely);
End;
End;
Function egyenlo(a,b:ido):boolean;
Begin
egyenlo:=false;
if (a.ora=b.ora) and (a.perc=b.perc) then egyenlo:=true;
End;
Function kerese(a:array of vonat;b:byte;t:vonat):byte;
Var i:byte;
Begin
kerese:=0;
for i:=1 to b do
Begin
End;
End;
Function idop(t:ido;p:byte):ido;
Begin
idop.perc:=(t.perc+p)Mod 60;
if (t.perc+p) div 60>0 then idop.ora:=t.ora+1 else idop.ora:=t.ora;
End;
Procedure szimulal;
Var aa,ab:byte;
max:vonat;
t:vonat;
i:byte;
Begin
max:=va[1];
for i:=1 to a do
Begin
if kisebb(va[i],max) then max:=va[i];
End;
for i:=1 to b do
Begin
if kisebb(vb[i],max) then max:=vb[i];
End;
for i:=1 to a do
Begin
va[i].erkezik:=idop(va[i].erkezik,f);
End;
for i:=1 to b do
Begin
vb[i].erkezik:=idop(vb[i].erkezik,f);
End;
t.indul.ora:=0;
t.indul.perc:=0;
max.indul:=idop(max.indul,1);
aa:=0;
ab:=0;
aa2:=0;
ab2:=0;
while kisebb(max,t) do
Begin
for i:=1 to a do
Begin
if egyenlo(va[i].erkezik,t.indul) then
Begin
ab:=ab+1;
End;
End;
for i:=1 to b do
Begin
if egyenlo(vb[i].erkezik,t.indul) then
Begin
aa:=aa+1;
End;
End;
for i:=1 to a do
Begin
if egyenlo(va[i].indul,t.indul) then
Begin
if aa=0 then
Begin
aa2:=aa2+1;
End
else aa:=aa-1;
End;
End;
for i:=1 to b do
Begin
if egyenlo(vb[i].indul,t.indul) then
Begin
if ab=0 then
Begin
ab2:=ab2+1;
End
else ab:=ab-1;
End;
End;
t.indul:=idop(t.indul,1);
End;
End;
Begin
assign(be,'tt-large.in');
reset(be);
assign(ki,'menetrend.ki');
rewrite(ki);
readln(be,N);
for i:=1 to N do
Begin
beolvas;
szimulal;
writeln(ki,'Case #',i,': ',aa2,' ',ab2);
End;
close(ki);
End.
|