90分求助
查看原帖
90分求助
186860
AlphaZe楼主2020/11/10 20:31

最后2个点WA啦_

#include <cstdio>
#include <cctype>
#include <algorithm>

using namespace std; 

#define ll unsigned long long

inline ll read() {
	ll res = 0, pdf = 0; char ch = getchar();
	while(!isdigit(ch)) pdf = ch == '-', ch = getchar();
	while(isdigit(ch)) res = (res << 3) + (res << 1) + (ch ^ 48), ch = getchar();
	return pdf ? -res : res;
}

const int N = 1e6 + 1; 
int n, m, c, k, flag[N]; 
struct Node {
	int p, q; 
	bool operator < (const Node &that) const {
		return q < that.q; 
	}
};
Node node[N]; 
ll a[N], need, ans, pow[N]; 
int stack[N], top, p; 

int main() {
//	freopen("zoo.in", "r", stdin);
//	freopen("zoo.out", "w", stdout);
    pow[0] = 1;
    for (int i = 1; i <= 64; ++i) pow[i] = pow[i - 1] * 2; 
    n = read(); m = read(); c = read(); k = read(); 
    for (int i = 1; i <= n; ++i) { 
        a[i] = read();
        need |= a[i]; 
	}
    for (int i = 1; i <= m; ++i) 
        node[i].p = read(), node[i].q = read();
    sort(node + 1, node + m + 1);
    for (int i = 1; i <= m + 1; ++i) {
    	if (node[i].q == node[i - 1].q) stack[++top] = node[i].p; 
    	else {
    		p = 0; 
    		for (int j = 1; j <= top; ++j) {
    			if ((need / (pow[stack[j]])) & 1) {
    				p = 1; 
    				break; 
				}
			}
			if (!p) {
				for (int j = 1; j <= top; ++j) {
					flag[stack[j]] = 1; 
				}
			}
    		top = 0; 
    		stack[++top] = node[i].p; 
		}
	}
	for (int i = 0; i < k; ++i) {
		if (!flag[i])
		    ++ans; 
	}
	if (k <= 63) { 
		ll print = pow[ans] - n; 
	    printf("%llu", print); 
	}
    else printf("1844674407370%llu", 9551616 - n);
	fclose(stdin); fclose(stdout); 
	return 0; 
}
2020/11/10 20:31
加载中...