好吧,再一次被水题虐了。

A. Lala Land and Apple Trees

敲码小技巧:故意添加两个苹果树(-1000000000, 0)和(1000000000, 0)(前者是位置,后者是价值)。

B. Amr and The Large Array

找出最长的是哪些数字,然后再对这些数字找最大区间。

我居然还想用两个指针加有限队列维护!TAT

C. Amr and Chemistry

首先,我们可以计算由x变为y的代价。O(1)
于是我枚举了\(a_0\)可以变为哪些数(最多\(m^2\)个,m是二进制的位数),然后O(n)统计大家都变为这个数需要的步数。所有情况取最小值就是答案。时间复杂度\(O(m^2n)\)。


神奇的树:

(不是我画的)

然后我们可以做树DP,O(n)就可以啦。

D. Guess Your Way Out! II

首先可以发现的是,那个高度并没有什么用,全都映射到高度为h的区间就好了。
然后就是区间交、并。

这个我是用了动态开节点的线段树来搞的。

正常解法:
题目给出两种信息,一是[l,r]之间没有出口,二是有出口。如果题目说[l,r]有出口,其实等价与说[\(2^{h-1}\), l)和(r,\(2^h\))都没出口。所以第二种信息可以变为第一种。那么只有一种信息就简单了,排序然后贪心一下就可以了。

E. A Simple Task

主要的思想是用数据结构进行快速的计数排序!没想到还能这么弄。

关于数据结构的话:

To solve Problem E, making a balanced binary tree that each node discribe some same character which located contigeously is much better than 26 segment trees, though both of their time complexities are O(szqlogn). It must because of the quantity of balanced binary tree is usually much less than segment tree. However, if it is sorting a long substring, balanced binary tree would delete many nodes and insert no more than 26 nodes; but the quantity of segment tree would not reduce. ——nodgd

Codeforces Round #312 (Div. 2)的更多相关文章

  1. Codeforces Round #312 (Div. 2) C. Amr and Chemistry 暴力

    C. Amr and Chemistry Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/558/ ...

  2. Codeforces Round #312 (Div. 2)B. Amr and The Large Array 暴力

    B. Amr and The Large Array Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contes ...

  3. Codeforces Round #312 (Div. 2) A. Lala Land and Apple Trees 暴力

    A. Lala Land and Apple Trees Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/cont ...

  4. Codeforces Round #312 (Div. 2) E. A Simple Task 线段树

    E. A Simple Task 题目连接: http://www.codeforces.com/contest/558/problem/E Description This task is very ...

  5. Codeforces Round #312 (Div. 2) E. A Simple Task 线段树+计数排序

    题目链接: http://codeforces.com/problemset/problem/558/E E. A Simple Task time limit per test5 secondsme ...

  6. Codeforces Round #312 (Div. 2) E. A Simple Task

    题目大意就是给一个字符串,然后多个操作,每次操作可以把每一段区间的字符进行升序或者降序排序,问最终的字符串是多少. 一开始只考虑字符串中字符'a'的情况,假设操作区间[L,R]中有x个'a',那么一次 ...

  7. Codeforces Round #312 (Div. 2) C.Amr and Chemistry

    Amr loves Chemistry, and specially doing experiments. He is preparing for a new interesting experime ...

  8. Codeforces Round #312 (Div. 2) B.Amr and The Large Array

    Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. ...

  9. Codeforces Round #312 (Div. 2) A.Lala Land and Apple Trees

    Amr lives in Lala Land. Lala Land is a very beautiful country that is located on a coordinate line. ...

  10. Codeforces Round #312 (Div. 2)小结

    爆炸了爆炸了...E题一个裸线段树没打完,A题wa了半天...... 爆炸了爆炸了....爆炸了爆炸了....rank270+滚粗 以后还是得多做模拟题...

随机推荐

  1. curl 返回响应头

    demo:/root# curl -i baidu.com HTTP/1.1 200 OK Date: Wed, 27 Jul 2016 08:50:03 GMT Content-Type: text ...

  2. 盘点:移动服务 #AzureChat

    感谢大家帮助我们顺利推出史无前例的 #AzureChat.移动服务和 Notification Hub 是 Windows Azure 平台上令人振奋的服务.我们很高兴能借这次在线讨论的机会,倾听各位 ...

  3. HDOJ 1429 胜利大逃亡(续) (bfs+状态压缩)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1429 思路分析:题目要求找出最短的逃亡路径,但是与一般的问题不同,该问题增加了门与钥匙约束条件: 考虑 ...

  4. 概率图模型(PGM)学习笔记(三)模式判断与概率图流

    我们依旧使用"学生网络"作为样例,如图1. 图1 首先给出因果判断(Causal Reasoning)的直觉解释. 能够算出来 即学生获得好的推荐信的概率大约是0.5. 但假设我们 ...

  5. Android4.3模拟器界面中右侧菜单按钮无法使用问题解决办法

    开发环境:笔记本电脑Windows2008+MyEclipse 10+Android4.3 问题描述:运行或者调试Android项目时,发现模拟器中右侧Menu按钮无法点击,截图如下: 查看在Andr ...

  6. Android SDK三种更新失败及其解决方法

    更新Android SDK,居然失败了三次. 1.第一次失败 出现Failed to fetch URL错误提示 Failed to fetch URL https://dl-ssl.google.c ...

  7. 关于python 模块导入

    如何将自己写的库加入到python的库路径中: 首先查看python包含的库路径,步骤如下: a.打开python命令界面 b.import  sys    c.sys.path 1.在python安 ...

  8. 关于UITableview刷新笔记

    今天在做项目的时候 发现调用tableview 的 reloaddata 方法的时候出现崩溃. - 具体操作是执行某个方法后将数据数组中的某条数据删除(数组中存数组)发现调用刷新方法后 程序崩溃,查看 ...

  9. 驱动: i2c驱动 >>>>

    1. IIC协议: <<um_s3c2440a_rev10.pdf>>  p481 Figure 20-3. IIC-Bus Interface Data Format< ...

  10. Web APIs 基于令牌TOKEN验证的实现

    Web APIs 基于令牌TOKEN验证的实现 概述: ASP.NET Web API 的好用使用过的都知道,没有复杂的配置文件,一个简单的ApiController加上需要的Action就能工作.但 ...