ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1612. Tram Forum

WR6
Posted by ZakharovRoman 3 Apr 2008 02:38
I do not understand why my solution gets wr6
like written correct do not understand why wr6(
this text my programm
------
var s:string;
    trol,tram,p:integer;
begin
  tram:=0;trol:=0;
  while not eof() do begin
    readln(s);
    s:=' '+s+' ';
    p:=pos('tram',s);
    if p>0 then begin
      if s[p-1]<>' ' then p:=0;
      if (p<>0)and (s[p+4]<>' ')then p:=0;
    end;
    while p>0 do begin
      inc(tram);
      delete(s,p,4);
      p:=pos('tram',s);
      if p>0 then begin
        if s[p-1]<>' ' then p:=0;
        if (p<>0)and (s[p+4]<>' ')then p:=0;
      end;
    end;

    p:=pos('trolleybus',s);
    if p>0 then begin
      if s[p-1]<>' ' then p:=0;
      if (p<>0)and (s[p+10]<>' ')then p:=0;
    end;
    while p>0 do begin
      inc(trol);
      delete(s,p,10);
      p:=pos('trolleybus',s);
      if p>0 then begin
        if s[p-1]<>' ' then p:=0;
        if (p<>0)and (s[p+10]<>' ')then p:=0;
      end;
    end;
  end;

  if trol=tram then writeln('Bus driver')
  else
  if tram>trol then writeln('Tram driver')
  else writeln('Trolleybus driver');
end.
Re: WR6
Posted by Vedernikoff Sergey 3 Apr 2008 02:54
Possibly, the shortest test on which this prog fails is:

trama tram
Re: WR6
Posted by ZakharovRoman 3 Apr 2008 03:33
Yes, you are right, after he changed me again wr6
I do not understand that why
this code:

var s,cur:string;
    trol,tram,i,fr:integer;
begin
  tram:=0;trol:=0;
  while not eof() do begin
    readln(s);
    s:=' '+s+' ';
    cur:='';fr:=0;
    for i:=1 to length(s) do begin
      if s[i]=' ' then begin
        inc(fr);
        if fr=2 then begin
         fr:=1;
         if cur='tram' then inc(tram);
         if cur='trolleybus' then inc(trol);
         cur:='';
        end;
      end
      else cur:=cur+s[i];
    end;
  end;

  if trol=tram then writeln('Bus driver')
  else
  if tram>trol then writeln('Tram driver')
  else writeln('Trolleybus driver');
end.

Edited by author 03.04.2008 03:34
Re: WR6
Posted by Vedernikoff Sergey 3 Apr 2008 04:55
This is even simpler to fail:

tram!
Re: WR6
Posted by ZakharovRoman 3 Apr 2008 15:26
on test tram! my programm prints 'Bus driver' because No there tram.
Re: WR6
Posted by ZakharovRoman 3 Apr 2008 15:39
Thanks I AC