40pts 求调
查看原帖
40pts 求调
560516
喵仔牛奶楼主2022/10/6 14:17

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;
}

2022/10/6 14:17
加载中...