#dp#CodeChef Little Elephant and Mouses】的更多相关文章

https://www.codechef.com/problems/LEMOUSE 题意: 有一个n *m的网格.有一头大象,初始时在(1,1),要移动到(n,m),每次只能向右或者向下走.有些格子中有老鼠,如果大象所在的格子和某个有老鼠的格子的曼哈顿距离$\e$1,大象就会被那只老鼠吓到.求一条移动路径,使得吓到过大象的老鼠数量最少.n;m $\le$100. 开始刷济南集训hzc的课件啦! 最简单的一道$DP$ 一只老鼠只会吓大象一次$f[i][j][0/1]$记录从左还是上走来的,转移时讨…
https://www.codechef.com/FEB14/problems/LEMOVIE 题意: 对于一个序列,定义其“激动值”为序列中严格大于前面所有数的元素的个数.给定n个数p1;,p2... pn,求这n个数的所有排列中,激动值不超过k的个数.$1 k \le n \le 200,1 \le pi \le 200$ 这种题有一个很神的想法: 把排列按某种顺序往里插入,使得后不会影响前 对于本题,先离散化去重后,从大到小插入,后插入的元素不会影响已经插入的元素严格大于前面所有数 $f[…
The Little Elephant likes permutations. This time he has a permutation A[1], A[2], ..., A[N] of numbers 1, 2, ...,N. He calls a permutation A good, if the number of its inversions is equal to the number of its local inversions. The number of inversio…
The Little Elephant from the Zoo of Lviv currently is on the military mission. There are N enemy buildings placed in a row and numbered from left to right strating from 0. Each building i (except the first and the last) has exactly two adjacent build…
Given an array A1,A2...AN, you have to print the size of the largest contiguous subarray such that LCM of all integers in that subarray is equal to the product of all integers in that subarray. Formally, For a subarray Ai,Ai+1...Aj where 1 ≤ i < j ≤…
类似墨墨的等式 设f[2][j][k]表示a[i].c是否和当前颜色相同,到当前枚举到的颜色为止,颜色数为j,对mnv取模为k的最小数 这是个无限循环背包,用spfa优化 #include<cstdio> #include<iostream> #include<cstring> #include<cstdlib> #include<algorithm> #include<cmath> #include<map> using…
https://www.codechef.com/problems/ANUCBC n个数字,选出其一个子集.求有多少子集满足其中数字之和是m的倍数.n $\le$ 100000,m $\le$ 100,最多90组数据 傻逼题模数取什么1e9+9毁我一节课该死煞笔提 [15:13:47]刚刚心塞了一会儿出去跑了几步好点了,然后发现好像是生物老师在艺术楼走廊上给人讲题(今天好像有学校给成绩好的单独上课之类的活动,好多同学都来了艺术楼的一个教室了和机房隔一个拐角........) #include <…
Little Elephant and Broken Sorting 怎么感觉这个状态好难想到啊.. dp[ i ][ j ]表示第 i 个数字比第 j 个数字大的概率.转移好像比较显然. #include<bits/stdc++.h> #define LL long long #define LD long double #define ull unsigned long long #define fi first #define se second #define mk make_pair…
https://www.codechef.com/problems/BLACKCOM 题意:一颗5000个黑白结点的树,10W个查询寻找是否存在大小s并且有t和黑节点的子图 一开始就觉得应当是一个树dp,但是总觉得怎么做怎么超时,用dp[5000][5000]预处理s大小t结点的可行性在时间复杂度上并不合理. 但是这题有一个结论,对于树上一个大小为s的子图而言,如果同时有可以存在r个黑色节点和l个黑色节点,则l - r之间的所有黑色节点都可以构造. 有了这个结论,就可以把dp方程转变为t结点的子…
题目链接: http://codeforces.com/problemset/problem/258/B B. Little Elephant and Elections time limit per test2 secondsmemory limit per test256 megabytes 问题描述 There have recently been elections in the zoo. Overall there were 7 main political parties: one…