GPT 話我知
本文是我在 g 指导的指导下将 gpt 语翻译为人类语的一次尝试,保证下文除前两句外均由本人完成。
官方题解只能做到
固定
这里有一个非常漂亮的构造双射消去的过程来证明这个结论。对于所有不包含
接下来只剩下包含
我们考虑根据这个结论去 dp,考虑记
实现细节是你其实不需要求出
代码甚至比
:::info[由人类编写的最优解代码]
#include<bits/stdc++.h>
#define rep(i,l,r) for (int i = l; i <= r; i ++)
#define rrp(i,l,r) for (int i = l; i >= r; i --)
using namespace std;
typedef long long LL;
typedef unsigned long long ull;
const int N = 10, M = (1 << 8) + 5, mod = 998244353;
inline void inc(int &x, int y) { x += y, x >= mod && (x -= mod); }
int power(int x, int y = mod - 2) {
int ans = 1;
for (; y; y >>= 1, x = 1LL * x * x % mod)
if (y & 1) ans = 1LL * ans * x % mod;
return ans;
}
int n, p[N][N];
void prework() {
int m; cin >> n >> m;
int c = max(n, m);
rep (i, 0, c - 1) rep (j, 0, c - 1) p[i][j] = 0;
rep (i, 0, n - 1) rep (j, 0, m - 1) cin >> p[i][j];
n = c;
int iv = power(100);
rep (i, 0, n - 1) rep (j, 0, n - 1)
p[i][j] = 1LL * p[i][j] * iv % mod;
}
int g[N][M], f[M][N][M], sum[M], a[M], pc[M];
void fakemain() {
prework();
rep (s, 1, (1 << n) - 1) pc[s] = pc[s >> 1] + (s & 1);
rep (i, 0, n - 1) rep (s, 0, (1 << n) - 1) {
g[i][s] = 1;
rep (j, 0, n - 1) if (~s >> j & 1)
g[i][s] = 1LL * g[i][s] * (mod + 1 - p[i][j]) % mod;
}
int ans = 0;
rep (k, 1, n) {
memset(f, 0, sizeof f);
rep (i, 0, n - 1) rep (s, 0, (1 << n) - 1)
f[(1 << i)][i][s] = g[i][s];
rep (s, 1, (1 << n) - 1) {
fill_n(sum, (1 << n), 0), fill_n(a, (1 << n), 0);
rep (x, 0, n - 1) if (s >> x & 1)
rep (t, 0, (1 << n) - 1) inc(a[t], f[s][x][t]);
rep (i, 0, n - 1) rep (t, 0, (1 << n) - 1)
if (t >> i & 1) inc(a[t], mod - a[t ^ (1 << i)]);
if (s == (1 << n) - 1) {
rep (t, 0, (1 << n) - 1) if (n - pc[t] < k) inc(ans, a[t]);
break;
}
rep (t, 0, (1 << n) - 1) a[t] = (pc[s] >= pc[t] + k) * a[t];
rep (i, 0, n - 1) rep (t, 0, (1 << n) - 1)
if (t >> i & 1) inc(a[t], a[t ^ (1 << i)]);
rep (x, 0, n - 1) if (~s >> x & 1) {
int ns = s | (1 << x);
rep (t, 0, (1 << n) - 1) {
f[ns][x][t] = (f[ns][x][t] + 1LL * (sum[t] + mod - a[t]) * g[x][t]) % mod;
}
} else {
rep (t, 0, (1 << n) - 1) inc(sum[t], f[s][x][t]);
}
}
}
cout << ans << '\n';
}
signed main() {
cin.tie(0)->ios::sync_with_stdio(0), cout.tie(0);
int c, T = 1;
cin >> T;
while (T --) fakemain();
}
:::