版本比较
题解:CF1210F1 Marek and Matching (easy version)
正文
增加 5 行删除 5 行
42 行未改动434445464747484950513 行未改动555657585959606162632 行未改动666768697070717273747576777879798081828312 行未改动9697989910010010110210342 行未改动 for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) cin >> p[i][j], p[i][j] = 1ll * p[i][j] * inv100 % Mod;
for(int S = 0; S < (1 << n); S++) { for(int T = 0; T < (1 << n); T++) { to[S][T] = no[S][T] = 1; for(int i = 0; i < n; i++) {3 行未改动 if((S >> j) & 1) res = 1ll * res * (Mod + 1 - p[j][i]) % Mod; to[S][T] = 1ll * to[S][T] * (Mod + 1 - res) % Mod; }
for(int i = 0; i < n; i++) { int res = 1; if(!((S >> i) & 1)) continue; for(int j = 0; j < n; j++)2 行未改动 no[S][T] = 1ll * no[S][T] * res % Mod; } } }
for(int S = 0; S < (1 << n); S++) for(int T = 0; T < (1 << n); T++) f[S][T] = g[S][T] = 0; for(int S = 0; S < (1 << n); S++) { for(int T = 0; T < (1 << n); T++) { if(!(S + T)) continue; g[S][T] = f[S][T] = to[S][T]; if(popc[S] <= popc[T]) g[S][T] = 0;
for(int SS = S; ; SS = (SS - 1) & S) { for(int TT = T; ; TT = (TT - 1) & T) { if(popc[S] > popc[T] && popc[SS] - popc[TT] >= popc[S] - popc[T]) upd(g[S][T], Mod - 1ll * g[SS][TT] * no[SS][T - TT] % Mod * f[S - SS][T - TT] % Mod);//如果 (SS, TT) 是更加优秀的代表元,减去这部分12 行未改动 cin.tie(0), cout.tie(0); for(int i = 0; i < (1 << N); i++) popc[i] = __builtin_popcount(i);// int T; cin >> T;// while(T--) // while(T--) init();}```