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)

导航