版本比较
题解:CF1210F2 Marek and Matching (hard version)
正文
增加 9 行删除 9 行
40 行未改动41424344454546474849505152525354555556575758596061626363646566677 行未改动757677787979808182833 行未改动878889909191929394957 行未改动1031041051061071071081091101112 行未改动11411511611711811811912012112240 行未改动int n;int p[N][N];int G[1<<N][1<<N],no[1<<N][1<<N];int g[1<<N][1<<N],f[1<<N][1<<N];
int main(){ freopen("magician.in","r",stdin); freopen("magician.out","w",stdout); ios::sync_with_stdio(false); cin.tie(0),cout.tie(0);
cin >> n; int inv=qmi(100,mod-2); for (int i=0;i<n;i++) for (int i=0;i<n;i++) { for (int j=0;j<n;j++) for (int j=0;j<n;j++) { cin >> p[i][j]; pro(p[i][j],inv); } }
for (int S=0;S<(1<<n);S++) { for (int T=0;T<(1<<n);T++) {7 行未改动 no[S][T]=1; for (int x=0;x<n;x++) if (S>>x&1) for (int y=0;y<n;y++) if (T>>y&1) pro(no[S][T],Mod(1-p[x][y])); } }
for (int S=0;S<(1<<n);S++) { for (int T=0;T<(1<<n);T++) {3 行未改动 for (int s=S;;s=(s-1)&S) { for (int t=T;;t=(t-1)&T) { if (s || t) if (s || t) if (g[s][t] && no[s][T^t] && f[S^s][T^t]) dec(f[S][T],(ll)g[s][t]*no[s][T^t]%mod*f[S^s][T^t]%mod); if (!t) break; }7 行未改动 { for (int t=T;;t=(t-1)&T) { if (s!=S || t!=T) if (popc(s)-popc(t)>=popc(S)-popc(T)) if (popc(s)-popc(t)>=popc(S)-popc(T)) if (g[s][t] && no[s][T^t] && f[S^s][T^t]) dec(g[S][T],(ll)g[s][t]*no[s][T^t]%mod*f[S^s][T^t]%mod); if (!t) break; }2 行未改动 } } } cout << f[(1<<n)-1][(1<<n)-1] << "\n";
return 0;}```:::