Cod sursa(job #18359)

Utilizator runnaway90Oprescu Radu Constantin runnaway90 Data 18 februarie 2007 11:45:23
Problema Amlei Scor 0
Compilator fpc Status done
Runda preONI 2007, Runda 2, Clasa a 10-a Marime 2.69 kb
var f,g:text;
    n,t,u,c,kolonel,i,j:longint;
    a:array[1..60] of longint;
    ok,ko:boolean;
begin
        assign(f,'amlei.in');
        assign(g,'amlei.out');
        rewrite(g);
        reset(f);
                while not(eof(f)) do
                begin
                        read(f,n,t,u);
                        ok:=true;
                        for i:=1 to n*t do
                        begin
                                c:=i mod n;
                                if c=0 then
                                        c:=n;
                                read(f,a[c]);
                                if a[c]<0 then
                                begin
                                        ko:=false;
                                end;
                                if c=n then
                             begin
                                ok:=true;
                                if ko=false then
                                 ok:=false;
                                 ko:=true;
                                if ok=true then
                                        break;
                             end;
                        end;
                        kolonel:=0;
                        if ok=true then
                        begin
                                kolonel:=1;
                                readln(f);
                        end;


                        ko:=true;
                        for i:=1 to n*u do
                        begin
                                c:=i mod n;
                                if c=0 then
                                        c:=n;
                                read(f,a[c]);
                                if a[c]<0 then
                                begin
                                        ko:=false;
                                end;
                                if c=n then
                             begin
                                ok:=true;
                                if ko=false then
                                ok:=false;
                                ko:=true;
                                if ok=true then
                                        break;
                             end;
                        end;
                        if (ok=true)and(kolonel=1) then
                           writeln(g,'DA')
                        else
                        if (ok=false)and(kolonel=0) then
                                writeln(g,'DA')
                        else
                                writeln(g,'NU');
                        readln(f);
                end;
        close(f);
        close(g);

end.