发布网友 发布时间:2024-10-23 21:35
共3个回答
热心网友 时间:2024-10-25 08:47
其实思路很简单,深搜就好了,热心网友 时间:2024-10-25 08:48
var n,i,j,ans:longint; a:array[1..20] of longint; v:array[1..20,1..20] of longint;procere search(i:longint);var j,k:longint; flag:boolean;begin if i=n+1 then begin inc(ans); exit; end; for j:=1 to 4 do begin flag:=true; for k:=1 to i do if (v[i,k]=1)and(j=a[k]) then flag:=false; if flag then begin a[i]:=j; search(i+1); end; end;end;begin readln(n); for i:=1 to n do begin for j:=1 to n do read(v[i,j]); readln; end; ans:=0; search(1); writeln(ans);end.热心网友 时间:2024-10-25 08:48
我有一题,和你的很像,但输入不同,所以对不起热心网友 时间:2024-10-25 08:47
其实思路很简单,深搜就好了,热心网友 时间:2024-10-25 08:48
var n,i,j,ans:longint; a:array[1..20] of longint; v:array[1..20,1..20] of longint;procere search(i:longint);var j,k:longint; flag:boolean;begin if i=n+1 then begin inc(ans); exit; end; for j:=1 to 4 do begin flag:=true; for k:=1 to i do if (v[i,k]=1)and(j=a[k]) then flag:=false; if flag then begin a[i]:=j; search(i+1); end; end;end;begin readln(n); for i:=1 to n do begin for j:=1 to n do read(v[i,j]); readln; end; ans:=0; search(1); writeln(ans);end.热心网友 时间:2024-10-25 08:48
我有一题,和你的很像,但输入不同,所以对不起