记录编号 39387 评测结果 AAAAAAAAAA
题目名称 项链制作 最终得分 100
用户昵称 Gravatarfuhao 是否通过 通过
代码语言 Pascal 运行时间 1.465 s
提交时间 2012-07-09 21:55:40 内存使用 1.77 MiB
显示代码纯文本
program necklacemn;
const maxset=70001; maxn=17; yu=1000000007;
var
 min,wxz,f:array[0..maxset] of int64;
 a,d:array[0..maxn] of longint;
 unable:int64; son,s,i,j,l,tot,n:longint;
 c:array[0..maxn,0..maxn] of longint;
begin
 assign(input,'necklacemn.in'); reset(input);
 assign(output,'necklacemn.out'); rewrite(output);
 readln(n);
 for i:=1 to n do
  for j:=1 to n do read(c[i,j]);
 for i:=1 to n do d[i]:=1 shl (i-1);
 s:=1 shl n-1;
 for i:=0 to s do
  begin
   tot:=0; min[i]:=maxlongint;
   for j:=1 to n do
    if i and d[j]=d[j] then
     begin
      if min[i]>d[j] then min[i]:=d[j];
      inc(tot); a[tot]:=j;
     end;
   wxz[i]:=1;
   for j:=1 to tot do
    for l:=j to tot do
     wxz[i]:=wxz[i]*(c[a[j],a[l]]+1) mod yu;
  end;
 for i:=0 to s do
  begin
   son:=i and (i-1);
   unable:=0;
   while son<>0 do
    begin
     if son and min[i]=min[i] then
     unable:=(unable+f[son]*wxz[i-son]) mod yu;
     son:=i and (son-1);
    end;
   f[i]:=((wxz[i]-unable) mod yu+yu) mod yu;
  end;
 writeln(f[s] mod yu);
 close(input); close(output);
end.