2010年12月19日

摘要: Backward Digit SumsTime Limit:1000MSMemory Limit:65536KDescriptionFJ and his cows enjoy playing a mental game. They write down the numbers from 1 to N (1 <= N <= 10) in a certain order and then sum adjacent numbers to produce a new list with one fewer number. They repeat this until only a sing 阅读全文
posted @ 2010-12-19 12:53 yming0221 阅读(155) 评论(0) 推荐(0)

2010年12月18日

摘要: 一看到该题就认为可以用最长公共子序列来解于是写了一下,提交显示MLE,改成循环数组又WA,不知道哪里问题看到别人的解法,感觉思维方式很特别,很好,循环长串指针,比较长串和短串的一位,如果相等,短串指针加一最后判断一下短串的指针有没有指到最后,如果移动到最后就说明查长串包含短串,否则.....也提醒一下自己的思维定势All in AllTime Limit:1000MSMemory Limit:30000KTotal Submissions:17955Accepted:7127DescriptionYou have devised a new encryption technique which 阅读全文
posted @ 2010-12-18 20:09 yming0221 阅读(114) 评论(0) 推荐(0)
摘要: 第一次用G++提交TLE,第二次用C++ 460ms水过!标记排列Time Limit:1000MSMemory Limit:30000KTotal Submissions:9419Accepted:4168Description题目描述:大家知道,给出正整数n,则1到n这n个数可以构成n!种排列,把这些排列按照从小到大的顺序(字典顺序)列出,如n=3时,列出1 2 3,1 3 2,2 1 3,2 3 1,3 1 2,3 2 1六个排列。任务描述:给出某个排列,求出这个排列的下k个排列,如果遇到最后一个排列,则下1排列为第1个排列,即排列1 2 3…n。比如:n = 3,k=2 给出排列2 3 阅读全文
posted @ 2010-12-18 19:25 yming0221 阅读(129) 评论(0) 推荐(0)
摘要: 这题就是最小生成树,不过样例输出看了好久,一看DISCUSS才知道,这题是SPJ,答案不唯一,不必管样例下面Kruskal+并查集一次AC!!NetworkTime Limit:1000MSMemory Limit:30000KTotal Submissions:7721Accepted:2835Special JudgeDescriptionAndrew is working as system administrator and is planning to establish a new network in his company. There will be N hubs in th 阅读全文
posted @ 2010-12-18 08:59 yming0221 阅读(125) 评论(0) 推荐(0)

2010年12月17日

摘要: 本题求将一个序列排序成有序序列所需要的最少交换次数,交换只能相邻交换可以知道,最少次数就等于原序列的逆序对数首先交换相邻的数,最多只能把逆序对数减一,而排序好的序列中逆序对数为0未排序好的序列中逆序对数不为0换句话说,至少需要交换“逆序对数”次才能把序列排序其次,只要序列不是有序的序列,就必然存在 i 使得 a[i]>a[i+1]这样,只要交换 i 和 i+1就能使逆序对数减一,换句话说,存在交换“逆序对数”次就能把序列排序的算法上界=下界,所以答案就是逆序对数...BrainmanTime Limit:1000MSMemory Limit:30000KDescriptionBackgr 阅读全文
posted @ 2010-12-17 21:43 yming0221 阅读(107) 评论(0) 推荐(0)
摘要: 本来想用c实现,可是还没来得及细细研究,这里用STL中的next_permutation水过标记一下,以后自己C实现题目地址http://poj.org/problem?id=1731OrdersTime Limit:1000MSMemory Limit:10000KDescriptionThe stores manager has sorted all kinds of goods in an alphabetical order of their labels. All the kinds having labels starting with the same letter are st 阅读全文
posted @ 2010-12-17 14:58 yming0221 阅读(119) 评论(0) 推荐(0)
摘要: 这题的题意并不难,就是根据不同车型的代号分别求出两个代号的“距离”然后根据距离选择一个最小的生成树,下面用Kruskal算法实现,虽然AC了,资源占用很大,还需改进Truck HistoryTime Limit:2000MSMemory Limit:65536KDescriptionAdvanced Cargo Movement, Ltd. uses trucks of different types. Some trucks are used for vegetable delivery, other for furniture, or for bricks. The company has 阅读全文
posted @ 2010-12-17 14:50 yming0221 阅读(126) 评论(0) 推荐(0)

2010年12月16日

摘要: 本题就是求最长递增子序列的长度,用动态规划Bridging signalsTime Limit:1000MSMemory Limit:10000KDescription'Oh no, they've done it again', cries the chief designer at the Waferland chip factory. Once more the routing designers have screwed up completely, making the signals on the chip connecting the ports of t 阅读全文
posted @ 2010-12-16 11:32 yming0221 阅读(151) 评论(0) 推荐(0)
摘要: 简单模拟Unix系统中的ls目录列表功能不过需要注意,在计算列数的时候是62/MAX_LEN,而不是60/MAX_LEN对字符数组排序使用了qsort()系统函数Unix lsTime Limit:1000MSMemory Limit:10000KDescriptionThe computer company you work for is introducing a brand new computer line and is developing a new Unix-like operating system to be introduced along with the new com 阅读全文
posted @ 2010-12-16 10:16 yming0221 阅读(147) 评论(0) 推荐(0)

2010年12月15日

摘要: 该题主要是简单的模拟,用递归实现可以用一个二维数组存储走到i,j位置时,所经历的步数DescriptionA robot has been programmed to follow the instructions in its path. Instructions for the next direction the robot is to move are laid down in a grid. The possible instructions areN north (up the page)S south (down the page)E east (to the right on 阅读全文
posted @ 2010-12-15 21:15 yming0221 阅读(146) 评论(0) 推荐(0)

导航