NOI2014 起床困难综合症 day1t1
感觉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 ;
}
巨丑无比的代码
NOI2014 起床困难综合症 day1t1的更多相关文章
- bzoj3668: [Noi2014]起床困难综合症
从高位到低位枚举期望的应该是ans最高位尽量取一.如果该数最高位为o的话能够取得1直接更新ans否则判断该位取1是否会爆m不会的话就加上. #include<cstdio> #includ ...
- NOI2014 起床困难综合症
3668: [Noi2014]起床困难综合症 Time Limit: 10 Sec Memory Limit: 512 MBSubmit: 225 Solved: 153[Submit][Stat ...
- BZOJ 3668: [Noi2014]起床困难综合症( 贪心 )
之前以为xor,or,and满足结合律...然后连样例都过不了 早上上体育课的时候突然想出来了...直接处理每一位是1,0的最后结果, 然后从高位到低位贪心就可以了... 滚去吃饭了.. ------ ...
- BZOJ 3668: [Noi2014]起床困难综合症【贪心】
3668: [Noi2014]起床困难综合症 Time Limit: 10 Sec Memory Limit: 512 MBSubmit: 2326 Solved: 1305[Submit][St ...
- Luogu 睡觉困难综合征 ([NOI2014]起床困难综合症)
一.[NOI2014]起床困难综合症 题目描述 网址:https://daniu.luogu.org/problemnew/show/2114 大意: 有一条链,链上每一个节点包含一个位运算f 与 一 ...
- P2114 [NOI2014]起床困难综合症(二进制)
P2114 [NOI2014]起床困难综合症 我们开始设俩数,一个二进制表示全是1,另一个全是0(就是2147483647 和 0 辣) 蓝后跑一遍门 于是最后有4种情况 1->0,1-> ...
- 洛谷P2114 [NOI2014]起床困难综合症
P2114 [NOI2014]起床困难综合症 题目描述 21世纪,许多人得了一种奇怪的病:起床困难综合症,其临床表现为:起床难,起床后精神不佳.作为一名青春阳光好少年,atm一直坚持与起床困难综合症作 ...
- bzoj千题计划238:bzoj3668: [Noi2014]起床困难综合症
http://www.lydsy.com/JudgeOnline/problem.php?id=3668 这..一位一位的来就好了呀 #include<cstdio> #include&l ...
- [NOI2014]起床困难综合症(二进制+贪心)
题目 [NOI2014]起床困难综合症 做法 先用全\(0\)和全\(1\)去运行一下,再在满足\(m\)的限制下,贪心地从高位到低位选择即可
随机推荐
- Codeforces Round #345 (Div. 2) B
B. Beautiful Paintings time limit per test 1 second memory limit per test 256 megabytes input standa ...
- bzoj 2457 [BeiJing2011]双端队列 模拟+贪心
[BeiJing2011]双端队列 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 457 Solved: 203[Submit][Status][D ...
- ACM.hdu1025
to get the ans of how many roads at most that can be built between two line without intersection of ...
- lightoj 1214
lightoj 1214 Large Division (大数除法) 链接:http://www.lightoj.com/volume_showproblem.php?problem=1214 题意 ...
- 35 个你也许不知道的 Google 开源项目
转载自:http://blog.csdn.net/cnbird2008/article/details/18953113 Google是支持开源运动的最大公司之一,它们现在总共发布有超过500个的开源 ...
- 51nod 1873 高精度计算
JAVA BigDecimal import java.util.*; import java.math.*; public class Main { public static void main( ...
- Maven-Dependency Mechanism
依赖管理是maven的一个广为人知的特性, 这也是maven擅长的一个领域. 为单一的工程管理依赖不是很难, 但当你着手处理多模块工程和包含数十或数百个模块的应用时, maven可以帮助你很好地保持高 ...
- java提取SVN提交log
http://wiki.svnkit.com/Printing_Out_Repository_History 这个介绍的相当详细. 总之就是要使用SVNKit包,下载地址.http://svnkit. ...
- js 数组&字符串 去重
Array.prototype.unique1 = function() { var n = []; //一个新的临时数组 for(var i = 0; i < this.length; i++ ...
- 网络知识===关于MAC地址和IP不能互相替代,缺一不可的原因
最近在看书<图解TCP/IP>书中分别谈到了IP和MAC地址.于是我就有两个疑惑, 为什么有了IP地址,我们还要获取MAC地址? 为什么我们初始不直接使用MAC地址作为终点地址?还要那么复 ...