分析:按位贪心即可。

program sleep;
var
a,g:array[..]of longint;
n,i,m,ans,t,len,x,y,v:longint;
c:char; s:string; e:boolean;
function cheak(x,y:longint):longint;
var i:longint;
begin
for i:= to n do
begin
if g[i]= then x:=x and (a[i] shr (y-) and );
if g[i]= then x:=x or (a[i] shr (y-) and );
if g[i]= then x:=x xor (a[i] shr (y-) and );
end;
exit(x);
end;
begin
assign(input,'sleep.in');
reset(input);
assign(output,'sleep.out');
rewrite(output);
readln(n,m);
for i:= to n do
begin
readln(s); t:=pos(' ',s); c:=s[];
if c='A' then g[i]:=;
if c='O' then g[i]:=;
if c='X' then g[i]:=;
val(copy(s,t+,length(s)-t),a[i]);
end;
ans:=; e:=false;
for i:= downto do
begin
if cheak(,i)= then begin x:=; y:=; end
else if cheak(,i)= then
begin
if (e=false)and(m shr (i-)=) then begin x:=; y:=; end
else begin x:=; y:=; end;
end
else begin x:=; y:=; end;
v:=v+x*( shl (i-));
ans:=ans+y*( shl (i-));
if v<m shr (i-) then e:=true;
end;
writeln(ans);
close(input); close(output);
end.

BZOJ 3668:起床困难综合症(贪心)的更多相关文章

  1. BZOJ 3668 起床困难综合症

    按位贪心. #include<iostream> #include<cstdio> #include<cstring> #include<algorithm& ...

  2. BZOJ 3668: [Noi2014]起床困难综合症( 贪心 )

    之前以为xor,or,and满足结合律...然后连样例都过不了 早上上体育课的时候突然想出来了...直接处理每一位是1,0的最后结果, 然后从高位到低位贪心就可以了... 滚去吃饭了.. ------ ...

  3. BZOJ3668: [Noi2014]起床困难综合症(贪心 二进制)

    Time Limit: 10 Sec  Memory Limit: 512 MBSubmit: 2708  Solved: 1576[Submit][Status][Discuss] Descript ...

  4. 【bzoj3668】[Noi2014]起床困难综合症 贪心

    原文地址:http://www.cnblogs.com/GXZlegend/p/6797090.html 题目描述 21 世纪,许多人得了一种奇怪的病:起床困难综合症,其临床表现为:起床难,起床后精神 ...

  5. [BZOJ3668] [Noi2014] 起床困难综合症 (贪心)

    Description 21 世纪,许多人得了一种奇怪的病:起床困难综合症,其临床表现为:起床难,起床后精神不佳.作为一名青春阳光好少年,atm 一直坚持与起床困难综合症作斗争.通过研究相关文献,他找 ...

  6. uoj #2 【NOI2014】起床困难综合症 贪心+位运算

    题目链接 给出n个数, 每个数有特定的一种操作, &|^三种, 给出一个m, 初始值属于[0,m],选定一个初始值, 使所有操作做完之后的值最大, 输出这个最大值. 1, 从最高位贪心, 如果 ...

  7. 【NOI2014】起床困难综合症 贪心

    从高到低按位贪心,讨论一下初始0或1,分别暴力算出结果是什么 如果一开始0就能得1当然直接ans垒起来 如果1能得1而且当前m够用,那也垒起来,同时m减掉 否则gg 2min的代码 #include ...

  8. bzoj3668 [Noi2014]起床困难综合症——贪心

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=3668 一开始想着倒序推回去看看这一位能不能达到来着,因为这样好中途退出(以为不这样会T): ...

  9. Luogu P2114_[NOI2014]起床困难综合症 贪心

    思路:按位贪心. 提交:1次 题解: 可以先处理出对于全$0$串和全$1$串最后每一位的结果.(每一位 从 $0$ $or$ $1$ 变成 $0$ $or$ $1$) 对于每一位,若不能变成$1$,则 ...

  10. BZOJ 3668: [Noi2014]起床困难综合症【贪心】

    3668: [Noi2014]起床困难综合症 Time Limit: 10 Sec  Memory Limit: 512 MBSubmit: 2326  Solved: 1305[Submit][St ...

随机推荐

  1. 微信订阅号 获取用户基本信息,登录及 php

    <?php //echo file_get_contents("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_cr ...

  2. date 参数(option)-d

    记录这篇博客的原因是:鸟哥的linux教程中,关于date命令的部分缺少-d这个参数的介绍,并且12章中的shell编写部分有用到-d参数 date 参数(option)-d与--date=" ...

  3. JS 定时器,定时调用PHP

    $(function() { var voiceplay=function(){ var site = location.href.split('_cms')[0] + '_cms/'; $.ajax ...

  4. 学习新框架laravel 5.6 (第一天)

    学习新框架第一天. composer 基本命令: composer list 获取帮助信息 composer init 以交互方式填写composer.json文件信息 composer instal ...

  5. 批量安装Python第三方库

    1.首先在python程序的文件夹内,新建一个文本文档,名字自定义,在文档中输入需要安装的第三方库,并用英文半角逗号隔开. import os def getTxt(): txt = open(&qu ...

  6. HyperLedger Fabric 1.4 交易流程(6.3)

    区块链最主要的特性之一是去中心化,没有了中心机构的集中处理,为了达成数据的一致性,就需要网络中全民参与管理,并以某种方法达成共识,所以区块链的交易流程也就是共识的过程.       在Fabric中, ...

  7. 【Leetcode】647. Palindromic Substrings

    Description Given a string, your task is to count how many palindromic substrings in this string. Th ...

  8. LeetCode:12. Integer to Roman(Medium)

    1. 原题链接 https://leetcode.com/problems/integer-to-roman/description/ 2. 题目要求 (1) 将整数转换成罗马数字: (2) 整数的范 ...

  9. android开发过程中项目中遇到的坑----布点问题

    我们在红点push 的到达和点击的地方,都加了布点.后来功能上了线,发现,每天的点击都比到达高! 这肯定不科学. 赶紧查问题,打开程序,发红点,关闭程序,布点上传.没问题.数据部门可以收到红点啊! 从 ...

  10. Win10启动不了的问题处理记录

    前几天电脑突然出现蓝屏的情况,而且使用Win10自带的修复功能根本没有卵用,修复不了,很郁闷,死活进不了系统了,说什么“INACCESSABE BOOT DEVICE”,好像是引导设备不可用. 到网上 ...