感觉NOI题在向简单方向发展,或者说明年会难到暴呢?
直接模拟啊,枚举每个二进制数位,看经过变换之后是否为1及为1的条件即可。\( O(nlogm)\)。
然后。。。跪了一个点,第五个死活比标准大一。。。
补码表示真dt,我会告诉你 1 >> 32 = 1吗(你肯定知道)?是我太傻逼了。
//{HEADS
#define FILE_IN_OUT
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <algorithm>
#include <iostream>
#include <fstream>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <complex>
#include <string>
#define REP(i, j) for (int i = 1; i <= j; ++i)
#define REPI(i, j, k) for (int i = j; i <= k; ++i)
#define REPD(i, j) for (int i = j; 0 < i; --i)
#define STLR(i, con) for (int i = 0, sz = con.size(); i < sz; ++i)
#define STLRD(i, con) for (int i = con.size() - 1; 0 <= i; --i)
#define CLR(s) memset(s, 0, sizeof s)
#define SET(s, v) memset(s, v, sizeof s)
#define mp make_pair
#define pb push_back
#define PL(k, n) for (int i = 1; i <= n; ++i) { cout << k[i] << ' '; } cout << endl
#define PS(k) STLR(i, k) { cout << k[i] << ' '; } cout << endl
using namespace std;
typedef long long LL;
typedef double DB;
typedef pair<int, int> i_pair;
const int INF = 0x3f3f3f3f;
//} const int maxn = 1e5 + ;
int ope[maxn], n, m;
bitset<> t[maxn];
char op[]; int me[][]; int main() {
freopen("sleep.in", "r", stdin);
freopen("sleep.out", "w", stdout); scanf("%d%d", &n, &m);
for(int i = ; i <= n; ++i) {
int tmp;
scanf("%s %d", op, &tmp);
t[i] = tmp;
// printf("%s\n", t[i].to_string().c_str());
if(strcmp(op, "OR") == ) {
ope[i] = ;
} else if(strcmp(op, "AND") == ) {
ope[i] = ;
} else {
ope[i] = ;
}
}
for(int i = ; i <= ; ++i) {
int init = ;
for(int j = ; j <= n; ++j) {
if(init == ) {
if(ope[j] == ) {
init = ;
} else if(ope[j] == ) {
if(t[j][i] == ) {
init = ;
} else if(t[j][i] == ) {
init = ;
}
} else {
if(t[j][i] == ) {
init = ;
} else if(t[j][i] == ) {
init = ;
}
}
} else if(init == ) {
if(ope[j] == ) {
if(t[j][i] == ) {
init = ;
}
} else if(ope[j] == ) {
if(t[j][i] == ) {
init = ;
} else if(t[j][i] == ) {
init = ;
}
} else {
if(t[j][i] == ) {
init = ;
} else if(t[j][i] == ) {
init = ;
}
}
}
}
me[i][] = init;
init = ;
for(int j = ; j <= n; ++j) {
if(init == ) {
if(ope[j] == ) {
init = ;
} else if(ope[j] == ) {
if(t[j][i] == ) {
init = ;
} else if(t[j][i] == ) {
init = ;
}
} else {
if(t[j][i] == ) {
init = ;
} else if(t[j][i] == ) {
init = ;
}
}
} else if(init == ) {
if(ope[j] == ) {
if(t[j][i] == ) {
init = ;
}
} else if(ope[j] == ) {
if(t[j][i] == ) {
init = ;
} else if(t[j][i] == ) {
init = ;
}
} else {
if(t[j][i] == ) {
init = ;
} else if(t[j][i] == ) {
init = ;
}
}
}
}
me[i][] = init;
}
int ans = ;
int bit = ;
/* 卧槽!!吧bit改成32就wa了一个点
* 出题人真良心没卡我
* 不然就10分了QAQ
* */
bool free_flag = false;
for(int i = bit; <= i; --i) {
if(free_flag) {
if(me[i][] == || me[i][] == ) {
ans += ( << i);
}
continue;
}
if(me[i][] == ) {
ans += ( << i);
if((m >> i) & ) {
free_flag = true;
}
} else if(me[i][] == ) {
if((m >> i) & ) {
ans += ( << i);
}
} else if((m >> i) & ) {
free_flag = true;
}
}
printf("%d\n", ans);
fclose(stdin);
fclose(stdout);
return ;
}
巨丑无比的代码