80分求助,为什么被卡了
查看原帖
80分求助,为什么被卡了
249422
TinyMirror1楼主2020/11/13 16:37

用所有动物减去已经有的和不能养的动物

13--16,4个点被卡了

#include <iostream>
#include <cstdio>
using namespace std;
typedef unsigned long long ull;
const int maxn = 1e6 + 5;
inline int read() {
	int x = 0;
	char ch = getchar();
	while (ch < '0' || ch > '9') {
		ch = getchar();
	}
	while (ch >= '0' && ch <= '9') {
		x = x * 10 + (ch ^ 48);
		ch = getchar();
	}
	return x;
}
ull ani, a[maxn], b[maxn];
int f[100];
ull cal(int n, int m) {
	ull res = ((ull)1 << (n - m));
	ull k = (((ull)1 << m) - 1);
	return res * k;
}
int main() {
//	freopen("zoo.in", "r", stdin);
//	freopen("zoo.out", "w", stdout);
	int n = read(), m = read();
	int c = read(), k = read();
	if (n == 0 && m == 0 && k == 64) {
		cout << "18446744073709551616";
		return 0;
	}
	for (int i = 1; i <= n; i++) {
		int x = read();
		ani |= x;
	}
	for (int i = 1; i <= m; i++) {
		int x = read(), y = read();
		if (ani & ((ull)1 << x)) {
			f[x] = 1;
		} else {
			f[x] = -1;
		}
	}
	int cnt1 = 0, cnt2 = 0;
	for (int i = 0; i < k; i++) {
		if (f[i] == -1) cnt2++;
	}
	ull t = n;
	t += cal(k, cnt2);
	cout << ((ull)1 << (k - 1)) - t + ((ull)1 << (k - 1));
	return 0;
}
2020/11/13 16:37
加载中...