{Joshua Nguyen

2/25/10

Contest #3

Team-Jr.

Enloe

Mr. Johnson}

Program ACSLJunior;

uses crt;

Type

            b_array=array[1..5,1..20] of integer;

    w_array=array[1..5,1..20] of integer;

    a_array=array[1..5] of integer;

    a1_array=array[1..5] of string;

Var

            a2:b_array;

    b:w_array;

    c:a_array;

    d:a_array;

    e:a_array;

 

Procedure input(Var a2:b_array;Var b:w_array;Var c,d,e:a_array);

Var

            h:integer;

    x:integer;

            f:integer;

    g:integer;

    q:integer;

 

Begin

            clrscr;

    f:=0;

    for q:=1 to 5 do

    begin

         writeln('Input the numbers of sticks for black for set ',q,'.');

         readln(c[q]);

         writeln('Input stick locations for black for set ',q,'.');

         for x:=1 to c[q] do

         Begin

                  readln(a2[q,x]);

         end;

         writeln('Input the numbers of sticks for white for set ',q,'.');

         readln(d[q]);

         writeln('Input stick locations for white for set ',q,'.');

         for x:=1 to d[q] do

         Begin

                  readln(b[q,x]);

         end;

         writeln('Input rods rolled');

         readln(e[q]);

    end;

 

end;

 

Procedure output(Var a2:b_array;Var b:w_array;Var c,d,e:a_array);

Var

            x:integer;

    l:a_array;

    f:a_array;

    z:a_array;

    j:a1_array;

    a:integer;

    q:integer;

 

Begin

            a:=0;

    for x:=1 to 5 do

    begin

            l[x]:=0;

    f[x]:=0;

    z[x]:=0;

    end;

    {l[1]:=a2[q,x]+e[1];}

    clrscr;

    for q:=1 to 5 do

    begin

         l[q]:=a2[q,1]+e[q];

         for x:=2 to c[q] do

         Begin

              if l[q]=a2[q,x] then

                  Begin

                   j[q]:='CANNOT MOVE';

                   z[q]:=1;

              end;

         end;

 

 

 

 

 

         if a2[q,1]<26 then

         Begin

                  if l[q]>26 then

              Begin

                   l[q]:=26;

              end;

         end;

 

 

 

 

 

         if l[q]=27 then

         Begin

                  for x:=2 to c[q] do

              Begin

                   if a2[q,x]<>15 then

                   Begin

                                a:=a+1;

                                           end

                   else if a2[q,x]=15 then

                   Begin

                                l[q]:=27;

                   end;

              end;

         end;

 

 

 

         if a=c[q]-1 then

         Begin

                  f[q]:=1;

              l[q]:=15;

         end;

 

 

 

         if a2[q,1]=27 then

         Begin

                  if e[q]<>4 then

              Begin

                   l[q]:=27;

                   j[q]:='CANNOT MOVE';

                   z[q]:=1;

              end;

         end;

 

 

 

                 if a2[q,1]=28 then

         Begin

                  if e[q]<>3 then

              Begin

                   l[q]:=a2[q,1];

                   j[q]:='CANNOT MOVE';

                   z[q]:=1;

              end;

         end;

 

 

 

         if a2[q,1]=29 then

         Begin

                  if e[q]<>2 then

              Begin

                   l[q]:=a2[q,1];

                   j[q]:='CANNOT MOVE';

                   z[q]:=1;

              end;

         end;

 

 

 

         if l[q]>30 then

         Begin

              j[q]:='DONE';

              z[q]:=1;

         end;

 

    {----------------------}

         if (z[q]=1) and (f[q]=0) then

         Begin

                writeln(q,'. ',j[q]);

         end

         else if (z[q]<>1) or (f[q]<>0) then

         Begin

                writeln(q,'. ',l[q]);

         end;

    end;

 

end;

 

Begin

            input(a2,b,c,d,e);

    output(a2,b,c,d,e);

            readln;

End.