Cod sursa(job #37932)

Utilizator floringh06Florin Ghesu floringh06 Data 25 martie 2007 13:07:19
Problema Bowling Scor 0
Compilator fpc Status done
Runda Arhiva de probleme Marime 1.27 kb
{$IFDEF NORMAL}
  {$I-,Q-,R-,S-}
{$ENDIF NORMAL}
{$IFDEF DEBUG}
  {$I+,Q+,R+,S-}
{$ENDIF DEBUG}
{$IFDEF RELEASE}
  {$I-,Q-,R-,S-}
{$ENDIF RELEASE}

var fi,fo:text;
    i,j,n,T,ind,k,ct:word;
    a,par:array[1..50001] of integer;



begin
 assign(fi,'bowling.in'); reset(fi);
 assign(fo,'bowling.out'); rewrite(fo);
 readln(fi,T);
 for i:=1 to T do
  begin
   ind:=0;
   read(fi,n);
   for j:=1 to n do
    read(fi,a[j]);
   j:=1;
   k:=1;
   a[n+1]:=0;
   ct:=0;
   while j<=n+1 do
    begin
      if a[j]=1 then inc(ct);
      if (a[j]=0) and (ct>0) then
      begin
       par[k]:=ct;
       inc(k);
       ct:=0;
      end;
     inc(j);
    end;
   dec(k);
   if (k=1) and (par[1]=2) then
    begin
     writeln(fo,'Nargy');
     continue;
    end;
   if (k=2) and (par[1]<=2) and (par[2]<=2) then
    begin
     writeln(fo,'Fumeanu');
     continue;
    end;
   ind:=0;
   for j:=1 to k do
    if k-j mod 2=0 then
     if (par[j]=1) or (par[j]=2) then
      par[j]:=0;
   for j:=1 to k do
   begin
    if k-j mod 2=1 then  if ind=0 then ind:=1 else ind:=0;
    if par[j]=1 then if j<>k then  if ind=0 then ind:=1 else ind:=0;
   end;
   if ind=0 then writeln(fo,'Nargy')
    else writeln(fo,'Fumeanu');
 end;
close(fo);
end.