起床困难综合症

按位贪心

忘了

就是对于每一位其实是各样的

考虑每一位如何成为贡献

初始为0之后变为1

初始为1最后还是1

对每一位统计

#include <bits/stdc++.h>
using namespace std ;

#define rep(i, a, b) for (int i = a; i <= b; i++)
#define per(i, a, b) for (int i = a; i >= b; i--)
#define siz(a) (int) a.size()
#define pb push_back
#define mp make_pair
#define ll long long
#define fi first
#define se second

const int N = 100010 ;

int n, m, c ;
int a = 0, b = (1 << 30) - 1, x ; 
string s ;

signed main() {
	scanf("%d%d", &n, &m) ;
	rep(i, 1, n) {
		cin >> s >> x ;
		if (s[0] == 'A') a &= x, b &= x ;
		if (s[0] == 'O') a |= x, b |= x ;
		if (s[0] == 'X') a ^= x, b ^= x ; 
	}
	rep(i, 0, 29) 
	if ((a & (1 << i)) || ((b & (1 << i)) && c < m)) c |= 1 << i ;
	printf("%d\n", c) ; 
	return 0 ;
}

posted @ 2020-10-14 22:34  harryhqg  阅读(162)  评论(0编辑  收藏  举报