Cod sursa(job #242985)

Utilizator nod_softwareBudisteanu Ionut Alexandru nod_software Data 11 ianuarie 2009 17:08:34
Problema Tablete Scor 10
Compilator fpc Status done
Runda Arhiva de probleme Marime 1.28 kb
program tablete;

{$APPTYPE CONSOLE}

uses
  SysUtils;
 var i,j,n,k,t:integer;fin,fout:text; b,curent:longint;
 a:array [1..1000,1..1000] of integer;
 use:array [1..1000001] of byte;
begin

assign (fin,'tablete.in');reset(fin);
assign(fout,'tablete.out');rewrite(fout);
readln(fin,n,k);
b:=1 ; curent:=1;
for i:=1 to n do begin
for j:=1 to n do begin
                     if j=k then begin
                                   if b mod 2 =0 then begin
                                                                a[i,k]:=b ;use [b]:=1;
                                                           end  else begin
                                                                        a[i,k]:=b+1; use[b+1]:=1;
                                                                      end;
                                 end else begin
                                 while use[curent]=1 do inc(curent);
                                             a[i,j]:=curent;use [curent]:=1;inc(curent);
                                         end;
                 b:=b+1; 
                 end;
                 end;
for i:=1 to n do begin
for j:=1 to n do begin
                      write(fout,a[i,j],' ');
                 end; writeln(fout);
                 end;
close(fout);
end.