Old Sorting Time Limit:2000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu Submit Status Practice LightOJ 1166 Description Given an array containing a permutation of 1 to n, you have to find the minimum number of swaps to sort the array…
S - Making the Grade POJ - 3666 这个题目要求把一个给定的序列变成递增或者递减序列的最小代价. 这个是一个dp,对于这个dp的定义我觉得不是很好想,如果第一次碰到的话. 上网看了一下题解,dp[i][j]表示前面 i 位已经是有序的了,第 i+1 位变成第j大的最小代价. 这个转移可以保证有序这个条件. 递增递减d两次. 这个题目要离散化,为什么要离散化呢,推荐博客 我以前就是感觉数据大就要离散化,不然数组存不下,不过看了这篇题解感觉他讲的很对啊. #include…
A Simple Tree Problem Time Limit: 3000ms Memory Limit: 65536KB This problem will be judged on ZJU. Original ID: 368664-bit integer IO format: %lld Java class name: Main Prev Submit Status Statistics Discuss Next Type: None None Graph Theory 2-…