首页 技术 正文
技术 2022年11月18日
0 收藏 425 点赞 3,940 浏览 2392 个字

感觉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 ;
}

巨丑无比的代码

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,491
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,907
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,740
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,492
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:8,132
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,293