1 | /** Aug 24, 2015 11:15:57 AM |
折腾了过长的时间,原因:
这不是通常意义上的可随意匹配的二分图。
既然是二分图,就有把节点分为两类的依据。
由题中给定的结合规则,一定是一个(x+y)为偶数的点与一个(x+y)为奇数的点相匹配,且是相邻点的匹配。
所以会将两类点分别加入两个表中,并进行hash操作节约存储空间。
“奇”的点总是不少于“偶”的点?
1 | /** Aug 24, 2015 11:15:57 AM |
折腾了过长的时间,原因:
这不是通常意义上的可随意匹配的二分图。
既然是二分图,就有把节点分为两类的依据。
由题中给定的结合规则,一定是一个(x+y)为偶数的点与一个(x+y)为奇数的点相匹配,且是相邻点的匹配。
所以会将两类点分别加入两个表中,并进行hash操作节约存储空间。
“奇”的点总是不少于“偶”的点?
poj 3253 Fence Repair 最小堆 优先队列 哈夫曼树
Description
Farmer John wants to repair a small length of the fence around the pasture. He measures the fence and finds that he needs N (1 ≤ N ≤ 20,000) planks of wood, each having some integer length Li (1 ≤ Li ≤ 50,000) units. He then purchases a single long board just long enough to saw into the N planks (i.e., whose length is the sum of the lengths Li). FJ is ignoring the “kerf”, the extra length lost to sawdust when a sawcut is made; you should ignore it, too.
FJ sadly realizes that he doesn’t own a saw with which to cut the wood, so he mosies over to Farmer Don’s Farm with this long board and politely asks if he may borrow a saw.
Farmer Don, a closet capitalist, doesn’t lend FJ a saw but instead offers to charge Farmer John for each of the N-1 cuts in the plank. The charge to cut a piece of wood is exactly equal to its length. Cutting a plank of length 21 costs 21 cents.
Farmer Don then lets Farmer John decide the order and locations to cut the plank. Help Farmer John determine the minimum amount of money he can spend to create the N planks. FJ knows that he can cut the board in various different orders which will result in different charges since the resulting intermediate planks are of different lengths.Input
Line 1: One integer N, the number of planks
Lines 2..N+1: Each line contains a single integer describing the length of a needed plankOutput
Line 1: One integer: the minimum amount of money he must spend to make N-1 cutsSample Input
3
8
5
8Sample Output
34Hint
He wants to cut a board of length 21 into pieces of lengths 8, 5, and 8.
The original board measures 8+5+8=21. The first cut will cost 21, and should be used to cut the board into pieces measuring 13 and 8. The second cut will cost 13, and should be used to cut the 13 into 8 and 5. This would cost 21+13=34. If the 21 was cut into 16 and 5 instead, the second cut would cost 16 for a total of 37 (which is more than 34).
犯过以下错误:
误用二分
元素删除后未完成堆的调整操作
最小堆写成了最大堆
long类型的res用了int类型
1 | import java.io.*; |
- Problem Description
Mike does not want others to view his messages, so he find a encode method Base64.
Here is an example of the note in Chinese Passport.
The Ministry of Foreign Affairs of the People’s Republic of China requests all civil and military authorities of foreign countries to allow the bearer of this passport to pass freely and afford assistance in case of need.When encoded by
Base64, it looks as followsVGhlIE1pbmlzdHJ5IG9mIEZvcmVpZ24gQWZmYWlycyBvZiB0aGUgUGVvcGxlJ3MgUmVwdWJsaWMgb2Yg
Q2hpbmEgcmVxdWVzdHMgYWxsIGNpdmlsIGFuZCBtaWxpdGFyeSBhdXRob3JpdGllcyBvZiBmb3JlaWdu
IGNvdW50cmllcyB0byBhbGxvdyB0aGUgYmVhcmVyIG9mIHRoaXMgcGFzc3BvcnQgdG8gcGFzcyBmcmVl
bHkgYW5kIGFmZm9yZCBhc3Npc3RhbmNlIGluIGNhc2Ugb2YgbmVlZC4=In the above text, the encoded result of
TheisVGhl. Encoded in ASCII, the charactersT,h, andeare stored as the bytes84,104, and101, which are the 8-bit binary values01010100,01101000, and01100101. These three values are joined together into a 24-bit string, producing010101000110100001100101.
Groups of 6 bits (6 bits have a maximum of2^6 = 64different binary values) are converted into individual numbers from left to right (in this case, there are four numbers in a 24-bit string), which are then converted into their corresponding Base64 encoded characters.
The Base64 index table is
0123456789012345678901234567890123456789012345678901234567890123 ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/ In the above example, the string
010101000110100001100101is divided into four parts010101,000110,100001and100101, and converted into integers21, 6, 33and37. Then we find them in the table, and get V, G, h, l.
When the number of bytes to encode is not divisible by three (that is, if there are only one or two bytes of input for the last 24-bit block), then the following action is performed:
Add extra bytes with value zero so there are three bytes, and perform the conversion to base64. If there was only one significant input byte, only the first two base64 digits are picked (12 bits), and if there were two significant input bytes, the first three base64 digits are picked (18 bits). ‘=’ characters are added to make the last block contain four base64 characters.
As a result, when the last group contains one bytes, the four least significant bits of the final 6-bit block are set to zero; and when the last group contains two bytes, the two least significant bits of the final 6-bit block are set to zero.
For example, base64(A) = QQ==, base64(AA) = QUE=.
Now, Mike want you to help him encode a string forktimes. Can you help him?
For example, when we encode A for two times, we will get base64(base64(A)) = UVE9PQ==.
Input
The first line contains an integer T(T≤20) denoting the number of test cases.
In the following T lines, each line contains a case. In each case, there is a number k(1≤k≤5) and a string s. s only contains characters whose ASCII value are from 33 to 126(all visible characters). The length of s is no larger than 100.Output
For each test case, output Case #t:, to represent this is t-th case. And then output the encoded string.Sample Input
2
1 Mike
4 MikeSample Output
Case #1: TWlrZQ==
Case #2: Vmtaa2MyTnNjRkpRVkRBOQ==
粗暴的模拟题,但是赛场上的做法简直一根筋;
修正……
1 | /** |
#D.Doom
本题的唯一(赛场上难以发现的)突破口就是,输入数据任给的正整数,经过不超过30次“平方再取模”操作后都成为某一定值。
也有特别的卡long long边界而不卡unsigned long long的现象,Java中不存在无符号类型因而无法实现。
#E.Exam
贪心。。。
1 | /** Sep 6, 2015 8:40:50 PM |
#F.Friends
必须及时通过必要的暴力模拟来找出这个千呼万唤不出来的规律
1 | /** |
#J.Joyful
赛场上耗费不少精力的题。。。
我无论是赛中还是赛后都没明白一点:对一个矩形区域涂色次数的期望,就是对该区域各点涂色期望之和。
写代码时轻视了多个int类型值相乘越界的问题
1 | /** Sep 6, 2015 9:26:29 PM |
#A.Article
赛中没有耐心读完的题。。。赛后还读错了题意……
原来按“保存”键是不存在失败率的,这大大简化了问题模型(即可列出状态转移方程)。
1 | /** Sep 7, 2015 6:37:43 PM |
StreamTokenizer
double navl ——> 如果当前标记是一个数字,则此字段将包含该数字的值。
String sval ——> 如果当前标记是一个文字标记,则此字段包含一个给出该文字标记的字符的字符串。
static int TT_EOF ——>指示已读到流末尾的常量。
static int TT_EOL ——->指示已读到行末尾的常量。
static int TT_NUMBER——->指示已读到一个数字标记的常量。
static int TT_WORD ——-> 指示已读到一个文字标记的常量。
int ttype ——–> 在调用 nextToken() 方法之后,此字段将包含刚读取的标记的类型。
The StreamTokenizer class takes an input stream and parses it into “tokens”, allowing the tokens to be read one at a time,这些符号的拆分是按照空格来确定的。
查阅官方文档得知,它是不把数字作为字符处理的。它能取得的字符串是以大小写字母为内容的。
换行符也会被视作空格。
从效率角度上着想,能得到更佳的解决方案
1 | struct Edge |
来到如此遥远的地域挑战未知,少有惊喜却多有险阻。
第一个签到题D题的疏忽几乎引起我的疯狂WA。实际上只是简单的边界问题的处理(分数值等于0)胡牛和张学长的仔细列举检验奏效了。
我个人花大量精力为F题写的线段树惨烈地挂了。Lazy标记未能体现出应有的使用价值。多种不同的修改操作与统计操作的优先级,必是平时练习时漏洞密布之处。
E题简单的计算几何遭遇了一些磕绊。张学长所归纳的方程是正确的,只是计算过程中变量范围的设置不甚合理。
相比之下,A题递推的实现较为顺利。
I题和J题是既面熟又陌生的题型。尽管全队坚持到了最后一刻,却未能再争取关键的突破。
赛后听解题报告会,发现原题无不存在破解的可能性?
暑期的Github是不是应该活跃起来了?来个“commit中断就请饮料”的活动?
【150707】Blog主题更换 - Amativeness(改) → Clearision
感谢不知名的作者提供的Amativeness主题,附带了华丽的特效,更给我一个精美的CSS调试用样例。
可是面对多样化的文章、页面类型,背景有待完善。
WP-Touch插件未能及时更新,失去了移动端的前台支持。
所以下定决心,寻找自适应的主题,迎来了本blog第一次真正的主题更替。
钉子菊苣设计的Clearision主题就是这样的出彩而不浮华。
向着网页前台的无限设计机遇的原始森林探险。
改良Eclipse Java EE IDE,使它的界面更顺眼、更酷炫
从所给的【链接】 下载Dark Juno主题,它修改了Eclipse所有的视图的颜色,工具栏也变成了暗黑主题。另外还需要修改编辑器的颜色主题。
下载Eclipse的颜色主题(Color Themes)插件,可通过Eclipse的Marketplace找到Eclipse Color Theme插件。
主题包下载完成后,请解压到Eclipse安装目录的dropins子目录下。
重启Eclipse,并选择菜单”Preferences”->”General”->”Appearance”,并选择Dark Juno主题。
代码高亮的颜色主题在它的下级选项Color Theme中选择。
体验到如VS一般的酷黑风格了吧?
=================================================
其实本该是这个样子的,可是总有什么不一样的地方?
http://blog.csdn.net/chszs/article/details/8301884
===========2015-07补充============================
进入Settings->General->Keys,修改Context Assist项目,可提供代码补全的快捷键支持。
6月底7月初兴风作浪折腾UEFI+GPT+Clover+Mac
太久没更新博客了,原因之一是此番折腾的曲折历程!
在硬盘前部空余空间(上次折腾后的预留空间)建立了200MB的fat32分区,并用bcdboot命令写入了win7引导文件,炮制了一个有“水分”的EFI分区。
主板早已启用UEFI,自然重启操作系统成功。接着心一急,手一横,没切换到PE系统就动用DG专业版转换分区表格式。结果出乎意料,却合情合理,win 7直接蓝屏。
心急火燎地喊来PE,把分区表格式从GPT转回MBR,可是DG不配合工作,在即将转成时报错终止。
直到此时,看似MBR,实则硬盘分区表出了隐性故障。win7启动卡在飘动的徽标处,再也进不去了。
三番五次倒腾分区与分区表,多次取用先前的C盘的ghost备份镜像,没有实际作用。
经百度经验查实,win7及其安装光盘所带的diskpart能够安全实现MBR与GPT互转。可是代价是丢失所有分区。
赶紧备份所有必要资料,把win7安装镜像搬到U盘。较为耗时的流程。
这下分区表重建了,而后手动建立了各个所需的分区方休。
还通过电话激活解决了不少工具束手无策的额外的win7 UEFI激活问题。