November 22, 2022
const
nn=100;
type
int=longint;
var
G:array[1..nn,1..nn] of boolean;
D:array[1..nn,1..nn] of boolean;
A:array[1..nn] of int; an:int;
t:int; n,i,j:int;
function c(k:int):int;
begin
exit((k-1) mod n +1);
end;
procedure init;
var i,j:int;
t:char;
begin
fillchar(g,sizeof(g),false);
fillchar(d,sizeof(d),false);
an:=0;
readln(n);
for i:=1 to n do
begin
for j:=1 to n do
begin
read(t);
if t='1' then g[i,j]:=true;
end;
readln;
end;
end;
procedure test(i:int);
var
j,t:int;
begin
for t:=1 to n-1 do
begin
j:=c(i+t);
if d[i,j] and d[j,i] and g[i,j] then begin
inc(an);a[an]:=i;
exit;
end;
end;
end;
procedure print;
var i:Int;
begin
writeln(an);
for i:=1 to an do
writeln(a[i]);
end;
procedure main;
var l,i,j,k,t:int;
begin
for i:=1 to n-1 do
d[i,i+1]:=true;
d[n,1]:=true;
for l:=2 to n-1 do
for i:=1 to n do
begin
j:=c(i+l);
for t:=1 to l-1 do
begin
k:=c(i+t);
if D[i,k] and D[k,j] and (G[i,k] or G[j,k]) then
begin
D[i,j]:=true;
break
end;
end;
end;
end;
procedure patch;
var i,j:int;
begin
end;
begin
readln(t);
for i:=1 to t do
begin
init;main; patch;
for j:=1 to n do
test(j);
print;
end;
//readln(n)
end.
your code here
Posted by
xiaodao
Category: 日常