喵仔牛奶 @ 2022-10-06 14:17:15
https://www.luogu.com.cn/record/list?pid=P3622&user=560516
#include <bits/stdc++.h>
using namespace std;
const int N = 5e4 + 5, K = 6;
int n, m, pos, x, k1, k2, s1, s2, ans, a[N], qwq[N][1 << K], f[N][1 << K];
int main() {
cin >> n >> m;
for (int i = 1; i <= m; i ++) {
cin >> pos >> k1 >> k2, s1 = s2 = 0;
for (int j = 1; j <= k1; j ++)
cin >> x, s1 |= 1 << (x - pos + n) % n;
for (int j = 1; j <= k2; j ++)
cin >> x, s2 |= 1 << (x - pos + n) % n;
for (int j = 1; j < 1 << 5; j ++)
if ((j & s1) || (~j & s2)) qwq[pos][j] ++;
}
for (int k = 0; k < 1 << 5; k ++) {
memset(f[0], 0x8f, sizeof f[0]), f[0][k] = 0;
for (int i = 1; i <= n; i ++)
for (int j = 0; j < 1 << 5; j ++) {
int s = j << 1 & 30;
f[i][j] = max(f[i - 1][s], f[i - 1][s | 1]) + qwq[i][j];
}
ans = max(ans, f[n][k]);
}
cout << ans << '\n';
return 0;
}
by 喵仔牛奶 @ 2022-10-06 14:18:24
@喵仔牛奶 操你妈,你个傻逼,第 13 行 j
从 1
开始枚举了!
by Engulf @ 2022-10-06 14:38:47
我谔谔
by zyxawa @ 2023-01-28 16:21:53
6
by __max @ 2024-07-28 12:39:16
我谔谔