![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
wikioi
taoqick
这个作者很懒,什么都没留下…
展开
-
wikioi 1069 关押罪犯
按怨气值排序,把怨气值大的尽量排在两个监狱里,这一点很容易想到。。。 进一步分析,要注意到:如果没有形成环,只是链,把链条从中间切断即可,如图所示: 另外需要注意的是当形成环时:如果是包含偶数个节点的环,例如上图中的1——4,此时切断1--2,2--3,3--4,1--4,仍然不会有冲突;如果是包含奇数个节点的环,例如上图中的1——3,此时1,2,3之间无论怎样切割总会产生冲突原创 2013-08-18 11:18:27 · 1844 阅读 · 1 评论 -
wikioi 1553 互斥的数
当开一个特别长的数组时,会导致爆表,解决方案是使用map。 此题的解法是一次性淘汰两个,有些情况无奈之淘汰了一个,所以cnt / 2为删掉的元素个数。上代码: #include #include #include #include #include #include #include using namespace std; int N, K; mapmp; int转载 2013-08-19 17:56:54 · 1221 阅读 · 0 评论 -
CareerCup Generate all the possible substrings
Generate all the possible substrings using the characters of a given string. Write code. (The order of chars do not matter, i.e., ac ca) i/p: abc o/p: { a,b,c,ab,ac,bc,abc} --------------转载 2014-03-11 12:57:46 · 565 阅读 · 0 评论 -
1169 传纸条 动态规划
四位DP: #include #include #include #include #include #include #define max(a,b) a>b?a:b using namespace std; int m,n; int a[51][51]; int dp[51][51][51][51]; int main(){ int i,j,i1,i2,j1,j2; scanf("%d%原创 2014-04-18 11:05:50 · 1451 阅读 · 0 评论