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 1116. Piecewise Constant Function

Why I get WA? Pelase, help me!!!!!!!
Posted by Revenger and NSC 29 Dec 2001 23:31
My code:

Program t1116;

Const MaxN=15000;

Type Kusok=record A,B,Y :integer end;

Var F1,F2,F      :array[1..MaxN]of Kusok;
    n1,n2,i,j,n  :integer;
    j1,j2,i2     :integer;

begin
read(n1);for i:=1 to n1 do read(f1[i].a,f1[i].b,f1[i].y);
read(n2);for i:=1 to n2 do read(f2[i].a,f2[i].b,f2[i].y);
n:=0;
j1:=1;
j2:=1;
for j1:=1 to n1 do begin
 for i2:=j2 to n2 do begin
  if f1[j1].b<f2[i2].a then break;
  if (f1[j1].a<f2[i2].a)and(f1[j1].b>f2[i2].b) then begin
    n:=n+1;
    f[n].a:=f1[j1].a;
    f[n].b:=f2[i2].a;
    f[n].y:=f1[j1].y;
    f1[j1].b:=f2[i2].b;
   end else
  if (f1[j1].a<f2[i2].a)and(f1[j1].b<f2[i2].b) then begin
    n:=n+1;
    f[n].a:=f1[j1].a;
    f[n].b:=f2[i2].a;
    f[n].y:=f1[j1].y;
    f1[j1].a:=f1[j1].b;
    break;
   end else
  if (f1[j1].a>f2[i2].a)and(f1[j1].b<f2[i2].b) then begin
    f1[j1].a:=f1[j1].b;
    break;
   end else
  if (f1[j1].a>f2[i2].a)and(f1[j1].b>f2[i2].b) then begin
   f1[j1].a:=f2[i2].b;
  end;
 end;
 j2:=i2;
 if f1[j1].a<>f1[j1].b then begin
  n:=n+1;
  f[n]:=f1[j1];
 end;
end;
write(n,' ');
for i:=1 to n do write(f[i].a,' ',f[i].b,' ',f[i].y,' ');
writeln;
end.
Re: Why I get WA? Pelase, help me!!!!!!!
Posted by Christopher Moh 30 Dec 2001 01:27
Try the following input:

1 1 5 2
1 1 5 3

Output should be 0.
Re: Thank you! I get AC.
Posted by Revenger and NSC 30 Dec 2001 16:39
> Try the following input:
>
> 1 1 5 2
> 1 1 5 3
>
> Output should be 0.
Thank you)
Posted by VorobeY1326 16 Oct 2009 17:37