(CodeForces - 5C)Longest Regular Bracket Sequence time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output This is yet another problem dealing with regular bracket sequences. We should remind you t…
Painting The Fence(贪心+优先队列) 题目大意:给 m 种数字,一共 n 个,从前往后填,相同的数字最多 k 个在一起,输出构造方案,没有则输出"-1". 解题思路:贪心的思路,优先选择数量多的先填,这样会让最后剩余相同的数字数量最少,所以我们优先选数量最多的两种数字填,最后剩下的(某一种)就填到它前面的位置去,一定是和相同的填在一起,这里就不证明了,自己画下就可以得到.优先队列模拟即可. AC_Code /* */ #include <bits/stdc++.…
Codeforces Round #256 (Div. 2) C C. Painting Fence time limit per test 1 second memory limit per test 512 megabytes input standard input output standard output Bizon the Champion isn't just attentive, he also is very hardworking. Bizon the Champion d…
"Holiday is coming, holiday is coming, hurray hurray!" shouts Joke in the last day of his college. On this holiday, Joke plans to go to his grandmother's house located in Schematics village. Joke's grandmother's house is more than a hundred year…
题意 有n个黑帮(gang),每个黑帮有siz[i]个人,黑帮与黑帮之间有有向边,并形成了一个竞赛完全图(即去除方向后正好为一个无向完全图).在很多年前,有一些人参与了一次大型抢劫,参与抢劫的人都获得了一个真金条. 在这些年间,不同的黑帮之间进行了交易.具体过程是: 在时刻i,假如有一条边是u->v,那么u帮派中的i mod siz[u]号如果有金条(无论真假),并且v帮的i mod siz[v]没有任何金条,那么u中的这个人就会向v中的这个人一个假金条. 经过无数年的交易之后,各个帮派的金条拥…