摘要: poj 2299 一个乱序序列的 逆序数 = 在只允许相邻两个元素交换的条件下,得到有序序列的交换次数 归并排序的思想:先递归把序列拆分,然后合并 合并函数: 需要注意的是t=t+mid-i+1,t即是所求的逆序数。 比如序列91054,在第二次合并190时,0比1小,那么0肯定也会比1后面的9要小 阅读全文
posted @ 2017-04-14 16:10 Mel年 阅读(172) 评论(0) 推荐(0) 编辑
摘要: 例题一 poj 1753 Flip Game 题目的大概意思是每一次翻动一个格子,他周围的也会跟着进行翻动,看翻动几次可以使所有的格子都变成一种颜色。 4*4的一共16个格子,如果16个格子都被翻转了还是没有达到要求则不可能达成 用DFS深搜来枚举,每次翻动一个格子判断一次是否达成,若满足未达成并且 阅读全文
posted @ 2017-04-05 18:31 Mel年 阅读(454) 评论(0) 推荐(0) 编辑
摘要: 好久都没有做题了,从长沙回来之后一直就是看看QT,感觉自己真的要蠢死了><不开心不开心 题目大概意思就是从一个图里面去掉一个点,看看剩下多少个孤立点。 自己想了好大一会儿没有思路,看到网上一个代码,真是惊叹好神奇...>< 用遍历的方式,如DFS,将去掉的点设为1,然后遍历一次看看剩下多少个没有被遍 阅读全文
posted @ 2016-11-28 22:50 Mel年 阅读(281) 评论(0) 推荐(0) 编辑
摘要: To evaluate the performance of our first year CS majored students, we consider their grades of three courses only: C - C Programming Language, M - Mat 阅读全文
posted @ 2016-11-17 19:00 Mel年 阅读(116) 评论(0) 推荐(0) 编辑
摘要: Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The answer is "yes", if 6 is a decimal number and 110 is 阅读全文
posted @ 2016-11-16 20:40 Mel年 阅读(172) 评论(0) 推荐(0) 编辑
摘要: Given a sequence of K integers { N1, N2, ..., NK }. A continuous subsequence is defined to be { Ni, Ni+1, ..., Nj } where 1 <= i <= j <= K. The Maximu 阅读全文
posted @ 2016-11-15 19:30 Mel年 阅读(1240) 评论(0) 推荐(0) 编辑
摘要: At the beginning of every day, the first person who signs in the computer room will unlock the door, and the last one who signs out will lock the door 阅读全文
posted @ 2016-11-14 21:32 Mel年 阅读(158) 评论(0) 推荐(0) 编辑
摘要: Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output every digit of the sum in English. Input Specificat 阅读全文
posted @ 2016-11-14 09:40 Mel年 阅读(159) 评论(0) 推荐(0) 编辑
摘要: 1004. Counting Leaves (30) A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child. In 阅读全文
posted @ 2016-11-12 18:59 Mel年 阅读(1508) 评论(0) 推荐(0) 编辑
摘要: As an emergency rescue team leader of a city, you are given a special map of your country. The map shows several scattered cities connected by some ro 阅读全文
posted @ 2016-11-12 17:16 Mel年 阅读(371) 评论(0) 推荐(0) 编辑