CINEMA - Rạp chiếu phim

Tác giả: ll931110

Ngôn ngữ: Pascal

Program CINEMA;
        Const
                input  = '';
                output = '';
                  maxn = 1000;
        Var
                  a: array[1..maxn,1..maxn] of longint;
              m,n,k: longint;

Procedure solve;
          Var
                      f: text;
                u,v,i,s: longint;
          Begin
                Assign(f, input);
                        Reset(f);

                Fillchar(a, sizeof(a), 0);
                Readln(f, m, n);

                u:= 1;
                v:= 1;
                Readln(f, k);
                For i:= 1 to k do
                  Begin
                        Read(f, s);
                        While s > 0 do
                          Begin
                                dec(s);

                                If odd(u) then
                                  Begin
                                        a[u,v]:= i;
                                        inc(v);
                                        If v = n + 1 then
                                           Begin
                                                inc(u);
                                                v:= n;
                                           End;
                                  End
                                else
                                  Begin
                                        a[u,v]:= i;
                                        dec(v);
                                        If v = 0 then
                                           Begin
                                                inc(u);
                                                v:= 1;
                                           End;
                                  End;
                          End;
                  End;
          End;

Procedure printresult;
          Var
                  f: text;
                i,j: longint;
          Begin
                Assign(f, output);
                        Rewrite(f);

                For i:= 1 to m do
                  Begin
                        For j:= 1 to n do write(f, a[i,j], ' ');
                        Writeln(f);
                  End;

                Close(f);
          End;

Begin
        solve;
        printresult;
End.

Download