Codeforces Round #312 (Div. 2)
好吧,再一次被水题虐了。
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)的更多相关文章
- 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/ ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- Codeforces Round #312 (Div. 2) E. A Simple Task
题目大意就是给一个字符串,然后多个操作,每次操作可以把每一段区间的字符进行升序或者降序排序,问最终的字符串是多少. 一开始只考虑字符串中字符'a'的情况,假设操作区间[L,R]中有x个'a',那么一次 ...
- Codeforces Round #312 (Div. 2) C.Amr and Chemistry
Amr loves Chemistry, and specially doing experiments. He is preparing for a new interesting experime ...
- 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. ...
- 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. ...
- Codeforces Round #312 (Div. 2)小结
爆炸了爆炸了...E题一个裸线段树没打完,A题wa了半天...... 爆炸了爆炸了....爆炸了爆炸了....rank270+滚粗 以后还是得多做模拟题...
随机推荐
- 射频识别技术漫谈(21)——RC系列射频芯片的天线设计
个人感觉使用RC系列射频芯片开发卡片读写器,主要的关键点有两个,分别涉及硬件和软件.软件上的关键是如何正确设置RC系列射频芯片内部的64个寄存器,硬件上的关键则是RC系列射频芯片的天线设计.天线提供了 ...
- 使用 Windows Media Center 远程控制
http://windows.microsoft.com/en-us/windows/getting-started-windows-media-center#getting-started-wind ...
- png的格式及像素存储分析
从图片的数据块存储方式来看png分两种 1.索引色模式存储.png8的索引色透明就采取该种方式.该种方式是将颜色存在png的可选模块调色板中,调色板的色彩存储格式为RGB(各1byte).而图片的数据 ...
- mac 下安装和卸载 mysql
这里有一篇文章写得很详细: http://www.cnblogs.com/macro-cheng/archive/2011/10/25/mysql-001.html 关于卸载,我也百度了下.找了好几个 ...
- JavaScript 覆盖document.createElement 方法 解决window.close在火狐下不兼容问题)
近期项目遇到了问题,有个asp.net web程序仅仅能在IE7 执行.如今xp都淘汰了,大家都用IE8-IE11,因此这个web app也须要升级 适应全部IE版本号.照成IE版本号不兼容的问题主要 ...
- poj2342 Anniversary party【树形dp】
转载请注明出处,谢谢:http://www.cnblogs.com/KirisameMarisa/p/4316097.html ---by 墨染之樱花 [题目链接]http://poj.org/p ...
- linq to sql用partial扩展属性,创建一个部分类(用于多表连接)
1.在窗体中创建dataGridView显示表: using System; using System.Collections.Generic; using System.ComponentModel ...
- [译]Stairway to Integration Services Level 7 - SSIS 工作流管理中级
介绍 前一个章节我们对SSIS的优先约束做了初步了解,并且实验了MaxConcurrentExecutables 包属性的设置. 本文将测试“On Success”, “On Completion”, ...
- java反射机制入门04
需要jxl.jar package com.rainmer.main; import java.io.File; import java.io.IOException; import java.uti ...
- Clob对象转为字符串
项目中遇到一个问题,对方公司把打印好的报表数据存到数据库中,实际上就是把html存在Oracle中,然后需要我们在社保系统里进行查询. 但是他们把数据存放在B数据库,而我们的社保系统用的数据库是B.A ...