随笔分类 -  CF

摘要:有n+1个房间。从1-n个房间。每个房间有两扇门。一扇去i+1的房间另一扇去编号为pi的房间。 起点为1,终点为n+1,对应第i个各点,如果我奇数次到达,那么下一步走到a【i】的位子,如果是偶数次到达,那么下一步走到a【i】+1的位子。问到达n+1的房间至少要走多少次 解析: f(i,0)代表第一次 阅读全文
posted @ 2018-08-10 18:03 planche 阅读(141) 评论(0) 推荐(0)
摘要:题意:给出n个无序的数以及m个操作,每个操作由两个数组成,第一个数是操作的方式,第二个数 i 是操作的范围,若第一个数是1,则给 1-i 个数按升序排序,若第二个数是2,则给 1-i 个数按降序排列。输出所有操作完成后的序列。 阅读全文
posted @ 2018-08-06 23:31 planche 阅读(136) 评论(0) 推荐(0)
摘要:让你计算所有连续子序列的最大值-最小值的和。 (单调栈) 对于一个数Ai来讲,如果其有贡献的价值,要么是-Ai作为最小值,要么是Ai作为最大值。 那么Ans=ΣAi*maxn-Ai*minn. 阅读全文
posted @ 2018-08-06 05:53 planche 阅读(162) 评论(0) 推荐(0)
摘要:给出一个字母串,k满足:长度至少为k的字串一定包含某字母c,求最小的k 一个数组记录每个字母上一次出现的位置,用来计算另一个数组:记录每个字母与其相邻的相同字母的最大距离(设0和len两个位置一定有相同的字母),答案就是这个数组中的最小值啦~ 阅读全文
posted @ 2018-08-06 03:31 planche 阅读(266) 评论(0) 推荐(0)
摘要:const int N = 2e6 + 5;//开两倍空间 int n; arr p,cnt; int l,r,m; ll sum = 0,ans; int main() { // file("test"); sdf(n); For(i, 1, n) sdf(p[i]); For(i, 1, n) { sum += abs(p... 阅读全文
posted @ 2018-08-06 02:44 planche 阅读(196) 评论(0) 推荐(0)
摘要:kk people want to split nn candies between them. Each candy should be given to exactly one of them or be thrown away. The people are numbered from 11  阅读全文
posted @ 2018-05-01 18:43 planche 阅读(513) 评论(4) 推荐(0)
摘要:Connected undirected weighted graph without self-loops and multiple edges is given. Graph contains n vertices and m edges. For each edge (u, v) find t 阅读全文
posted @ 2018-04-22 23:27 planche 阅读(262) 评论(0) 推荐(0)
摘要:You have an array a with length n, you can perform operations. Each operation is like this: choose two adjacent elements from a, say xand y, and repla 阅读全文
posted @ 2018-04-10 13:56 planche 阅读(169) 评论(0) 推荐(0)
摘要:What are you doing at the end of the world? Are you busy? Will you save us? Nephren is playing a game with little leprechauns. She gives them an infin 阅读全文
posted @ 2018-04-10 13:52 planche 阅读(282) 评论(0) 推荐(0)
摘要:Oleg writes down the history of the days he lived. For each day he decides if it was good or bad. Oleg calls a non-empty sequence of days a zebra, if 阅读全文
posted @ 2018-04-07 14:15 planche 阅读(211) 评论(0) 推荐(0)
摘要:For a permutation P[1... N] of integers from 1 to N, function f is defined as follows: Let g(i) be the minimum positive integer j such that f(i, j) =  阅读全文
posted @ 2018-04-07 14:13 planche 阅读(343) 评论(0) 推荐(0)
摘要:A dragon symbolizes wisdom, power and wealth. On Lunar New Year's Day, people model a dragon with bamboo strips and clothes, raise them with rods, and 阅读全文
posted @ 2018-04-07 14:09 planche 阅读(262) 评论(0) 推荐(0)
摘要:You're given Q queries of the form (L, R). For each query you have to find the number of such x that L ≤ x ≤ R and there exist integer numbers a > 0,  阅读全文
posted @ 2018-04-05 18:25 planche 阅读(369) 评论(0) 推荐(0)
摘要:http://codeforces.com/problemset/problem/940/C And where the are the phone numbers? You are given a string s consisting of lowercase English letters a 阅读全文
posted @ 2018-03-22 22:40 planche 阅读(288) 评论(0) 推荐(0)
摘要:http://codeforces.com/problemset/problem/949/B Dima is a beginner programmer. During his working process, he regularly has to repeat the following ope 阅读全文
posted @ 2018-03-22 22:39 planche 阅读(215) 评论(0) 推荐(0)
摘要:http://codeforces.com/problemset/problem/935/B Two neighboring kingdoms decided to build a wall between them with some gates to enable the citizens to 阅读全文
posted @ 2018-03-21 22:45 planche 阅读(270) 评论(0) 推荐(0)
摘要:http://codeforces.com/problemset/problem/936/B Petya and Vasya arranged a game. The game runs by the following rules. Players have a directed graph co 阅读全文
posted @ 2018-03-20 22:34 planche 阅读(214) 评论(0) 推荐(0)
摘要:http://codeforces.com/problemset/problem/937/B The weather is fine today and hence it's high time to climb the nearby pine and enjoy the landscape. Th 阅读全文
posted @ 2018-03-20 22:33 planche 阅读(214) 评论(0) 推荐(0)
摘要:http://codeforces.com/problemset/problem/940/B Right now she actually isn't. But she will be, if you don't solve this problem. You are given integers  阅读全文
posted @ 2018-03-20 22:32 planche 阅读(254) 评论(0) 推荐(0)
摘要:http://codeforces.com/problemset/problem/946/D Ivan is a student at Berland State University (BSU). There are n days in Berland week, and each of thes 阅读全文
posted @ 2018-03-19 15:49 planche 阅读(296) 评论(0) 推荐(0)