ENG  RUS Timus Online Judge
Online Judge
Problems
Authors
Online contests
Site news
Webboard
Problem set
Submit solution
Judge status
Guide
Register
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1612. Tram Forum

Why WA on test 24?!
Posted by ilya_romanenko 27 May 2011 22:20
Please people help! Can anybody tell me test 24?

const
tr='tram';
trol='trolleybus';
mmm=' `~!@#\$%^&*()-_=+\\|[{]};:\",<.>/?¹0123456789';
var
tr1,tr2,a,b,c,i:integer;
s:widestring;
begin
b:=1;
tr1:=0;
tr2:=0;
c:=0;
while(not seekEOF)do
begin
c:=0;
while(pos(tr,s)>0)do begin
c:=0;
for i:=1 to 45 do
if(s[pos(tr,s)+4]=mmm[i])then  inc(c);
if(pos(tr,s)+4=length(s))then inc(c);
if((ord(pos(tr,s)+4)=39)or(ord(pos(tr,s)+4)=96))then inc(c);
if(c=0)then begin
delete(s,pos(tr,s),4);
end
else begin inc(tr1);
delete(s,pos(tr,s),4);
end;
end;
c:=0;
while(pos(trol,s)>0)do begin
c:=0;
for i:=1 to 45 do
if(s[pos(trol,s)+10]=mmm[i])then  inc(c);
if(pos(trol,s)+10=length(s))then inc(c);
if((ord(pos(trol,s)+10)=39)or(ord(pos(trol,s)+10)=96))then inc(c);
if(c=0)then begin
delete(s,pos(trol,s),10);
end
else begin
inc(tr2);
delete(s,pos(trol,s),10);
end;
end;
inc(b);
end;
if(tr1>tr2)then writeln('Tram driver')
else if(tr2>tr1)then writeln('Trolleybus driver')
else if(tr2=tr1)then writeln('Bus driver');
end.