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 CRASH(ACCESS VIOLATION) ON TEST 10?HELP ME!
Posted by Nero 14 May 2007 11:38
I DO NOT KOWN WHY WHENEVER I GET A CRASH ABOUT(ACCESS VIOLATION).
CAN SOMEBODY TELL ME WHY?

HERE IS MY PROGRAM:
{$M 10000}
program ru1116;
type
  node=record
         b,e,y:integer;
       end;
var
  n,nn,i,j,k,tot,b,e,y:integer;
  f1,f:array[1..100]of node;
  flag:array[-32000..32000]of boolean;

begin
//  assign(input,'input.in');reset(input);

    read(n);
    for i:=1 to n do
      with f1[i] do
        read(b,e,y);

    fillchar(flag,sizeof(flag),false);
    read(k);
    for i:=1 to k do
    begin
      read(b,e,y);
      for j:=b to e-1 do
        flag[j]:=true;
    end;


    tot:=0;
    k:=1;
    while k<=n do
    begin
      b:=f1[k].b;e:=f1[k].e;
      i:=b;
      repeat
        while not flag[i] and (i<e) do
          inc(i);
        if i>b
          then begin
                 inc(tot);
                 f[tot].b:=b;
                 f[tot].e:=i;
                 f[tot].y:=f1[k].y;
               end;
        while (i<=e)and(flag[i]) do
          inc(i);
        b:=i;
      until i>=e;
      inc(k);
    end;
    write(tot);
    for i:=1 to tot do
      write(' ',f[i].b,' ',f[i].e,' ',f[i].y);
end.