比赛 |
20100420 |
评测结果 |
AAATTTT |
题目名称 |
圆桌会议B |
最终得分 |
42 |
用户昵称 |
Achilles |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2010-04-20 10:17:46 |
显示代码纯文本
program dislike;
var
c,n,m,i,j,i1,i2,i3,p,p2,t2:integer;
tab:array[1..40,1..40]of integer;
ans:array[-2..100000,1..40]of shortint;
procedure find(c:shortint);
var
i:shortint;
begin
if c=n+1 then begin
p:=0;
ans[-2]:=ans[-1];
for i1:=1 to m do
begin
for i2:=1 to n do
begin
t2:=ans[-1,1];
for i3:=1 to n*1 do
ans[-1,i3]:=ans[-1,i3+1];
ans[-1,n]:=t2;
p2:=0;
for i3:=1 to n do
if ans[-1,i3]<>ans[i1,i3] then begin
p2:=1;
break;
end;
if p2=0 then begin
p:=1;
break;
end;
end;
if p=1 then break;
end;
ans[-1]:=ans[-2];
if p=0 then begin
for i1:=1 to n div 2 do
begin
t2:=ans[-1,i1];
ans[-1,i1]:=ans[-1,n+1-i1];
ans[-1,n+1-i1]:=t2;
end;
for i1:=1 to m do
begin
for i2:=1 to n do
begin
t2:=ans[-1,1];
for i3:=1 to n*1 do
ans[-1,i3]:=ans[-1,i3+1];
ans[-1,n]:=t2;
p2:=0;
for i3:=1 to n do
if ans[-1,i3]<>ans[i1,i3] then begin
p2:=1;
break;
end;
if p2=0 then begin
p:=1;
break;
end;
end;
if p=1 then break;
end;
end;
ans[-1]:=ans[-2];
if p=0 then begin
ans[-1]:=ans[-2];
m:=m+1;
ans[m]:=ans[-1];
end;
end
else begin
for i:=1 to n do
begin
if ans[0,i]=0 then begin
if c=1 then begin
ans[-1,1]:=i;
ans[0,i]:=1;
find(c+1);
ans[0,i]:=0;
end
else begin
if c=n then begin
if (tab[i,ans[-1,1]]=0)and(tab[ans[-1,1],i]=0)and(tab[i,ans[-1,c-1]]=0)and(tab[ans[-1,c-1],i]=0) then begin
ans[-1,c]:=i;
ans[0,i]:=1;
find(c+1);
ans[0,i]:=0;
end;
end
else begin
if (tab[i,ans[-1,c-1]]=0)and(tab[ans[-1,c-1],i]=0) then begin
ans[-1,c]:=i;
ans[0,i]:=1;
find(c+1);
ans[0,i]:=0;
end;
end;
end;
end;
end;
end;
end;
begin
assign(input,'dislike.in');
assign(output,'dislike.out');
reset(input);
rewrite(output);
readln(c,n);
while c<>0 do
begin
fillchar(ans,sizeof(ans),0);
for i:=1 to n do
begin
for j:=1 to n do
read(tab[i,j]);
readln;
end;
m:=0;
find(1);
writeln(c,' ',m);
for i:=1 to m do
begin
for j:=1 to n do
write(ans[i,j],' ');
writeln;
end;
readln(c,n);
end;
close(input);
close(output);
end.