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

Test 10,WA,who can give me the test???
Posted by tantian 1 Aug 2006 09:52
program ex;
var     a:Array[-32000..32000] of integer;
        b:Array[1..100000,1..2] of integer;
        i,j,k,n,x,y,z,s,first:longint;
begin
{        assign(input,'1116.in');reset(input);}
        read(n);
        for i:=-32000 to 32000 do a[i]:=101;
        for i:=1 to n do begin
                read(x,y,z);
                for j:=x to y-1 do
                        a[j]:=z;
        end;
        readln;
        read(n);
        for i:=1 to n do begin
                read(x,y,z);
                for j:=x to y-1 do
                        if a[j]<>101 then
                                a[j]:=101;
        end;
        k:=0;s:=0;
        for i:=-32000 to 32000 do begin
                if (a[i]<>101)and(k=0) then begin
                        k:=1;
                        first:=i;
                end;
                if (a[i]=101)and(k=1) then begin
                        k:=0;
                        inc(s);
                        b[s,1]:=first;b[s,2]:=i;
                end;
        end;
        write(s,' ');
        for i:=1 to s do
                write(b[i,1],' ',b[i,2],' ',a[b[i,1]],' ');
        writeln;
{        close(input);}
end.