memset(f,0x3f,sizeof f); f[1][0]=0; int f_s=(1<<n)-1; for(int s=1;s<=f_s;s+=2){ for(int x=0;x<n;++x){ if(!((s>>x)&1)) continue; // 走过了 x 点 for(int y=0;y<n;++y){ //if(!((s>>y)&1)) continue; // 走过 y 点 f[s][x]=min(f[s][x],f[s-(1<<x)][y]+w[y][x]); } } }
在上面的代码里面,为什么在状态转移里面,不判断是否走过 y 点也是对的。
应该不算贴代码吧。