Wed, 10 Jul 2019 18:45:26 +0800
parent
fbc2949ca0
commit
fd2c5403d8
@ -1,29 +1,50 @@
|
|||||||
#include <cstdio>
|
#include <bits/stdc++.h>
|
||||||
int a[100010], n, m;
|
using namespace std;
|
||||||
char op[100010], buf[10];
|
const int N = 1e5 + 50;
|
||||||
int calc(int x)
|
unsigned T[N];
|
||||||
{
|
char op[N][4];
|
||||||
for (int i = 0; i < n; i++)
|
bool can[32];
|
||||||
{
|
int main()
|
||||||
if (op[i] == 'A') x &= a[i];
|
{
|
||||||
if (op[i] == 'O') x |= a[i];
|
int n, m;
|
||||||
if (op[i] == 'X') x ^= a[i];
|
scanf("%d%d", &n, &m);
|
||||||
}
|
for (int i = 0; i < n; i++)
|
||||||
return x;
|
scanf("%s%u", op[i], T + i);
|
||||||
}
|
for (int i = 0; i < 32; i++)
|
||||||
int main()
|
{
|
||||||
{
|
int x = 1;
|
||||||
scanf("%d%d", &n, &m);
|
for (int j = 0; j < n; j++)
|
||||||
for (int i = 0; i < n; i++)
|
switch (*op[j])
|
||||||
{
|
{
|
||||||
scanf("%s%d", buf, a + i);
|
case 'A':
|
||||||
op[i] = buf[0];
|
x = x & (T[j] >> i) & 1;
|
||||||
}
|
break;
|
||||||
int cur = 1, ans = 0;
|
case 'O':
|
||||||
while (cur <= m) cur <<= 1;
|
x = x | (T[j] >> i) & 1;
|
||||||
for (cur >>= 1; cur; cur >>= 1)
|
break;
|
||||||
if ((!(calc(0) & cur)) && (ans + cur <= m) && (calc(cur) & cur))
|
case 'X':
|
||||||
ans += cur;
|
x = x ^ (T[j] >> i) & 1;
|
||||||
printf("%d", calc(ans));
|
break;
|
||||||
return 0;
|
}
|
||||||
}
|
can[i] = x;
|
||||||
|
}
|
||||||
|
unsigned ans = 0;
|
||||||
|
for (int i = 0; i < 32; i++)
|
||||||
|
if (can[i] && (ans | (1 << i)) <= m)
|
||||||
|
ans |= 1 << i;
|
||||||
|
for (int j = 0; j < n; j++)
|
||||||
|
switch (*op[j])
|
||||||
|
{
|
||||||
|
case 'A':
|
||||||
|
ans &= T[j];
|
||||||
|
break;
|
||||||
|
case 'O':
|
||||||
|
ans |= T[j];
|
||||||
|
break;
|
||||||
|
case 'X':
|
||||||
|
ans ^= T[j];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
printf("%u", ans);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in new issue