dp[i][0]表示i号兔子先于i-1号兔子喂食,dp[i][1]反过来. 倒着DP D. Dima and Hares time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Dima liked the present he got from Inna very much. He liked the present he got…
CF358D Dima and Hares 洛谷评测传送门 题目描述 Dima liked the present he got from Inna very much. He liked the present he got from Seryozha even more. Dima felt so grateful to Inna about the present that he decided to buy her nn hares. Inna was very happy. She l…
http://codeforces.com/contest/366/problem/D 遍历下界,然后用二分求上界,然后用dfs去判断是否可以. #include <cstdio> #include <cstring> #include <algorithm> #define maxn 10000 using namespace std; int n,m; int head[maxn]; bool vis[maxn]; int e; int pl[maxn],pr[ma…
题目:http://codeforces.com/problemset/problem/366/E 事实上就是找 n * m 矩阵中数字 x 和 数字 y 的最远距离. 方法參照武森的论文<浅谈信息学中的"0"和"1"> 先约定符号:xi,xj (i,j)是x的下标,当然.矩阵中的值是能够反复的 上面是武森的论文原文.加上我之前的符号约定,我在做点解释: 事实上那个max={四种可能} 更好的写法是: |xi-yi|+|xj-yj|=max((1),…
从本质入手,这个东西影响取值的就是相邻两个哪个先取 设f[i][0/1]为前i个(i-1,i)中先取i/i-1的值(这里不算上i的贡献 转移就显然了,注意要先复制-inf #include<iostream> #include<cstdio> using namespace std; const int N=3005; int n,a[N],b[N],c[N],f[N][2]; int main() { scanf("%d",&n); for(int i…
A - Dima and Continuous Line 水题:直接模拟: #include<cstdio> #define maxn 1005 using namespace std; int x[maxn],y[maxn]; int main() { int n,a,b,last; scanf("%d",&n); ; ;i<n;i++) { scanf("%d",&b); a=last; last=b; )continue; i…
CF1252J Tiling Terrace 洛谷评测传送门 题目描述 Talia has just bought an abandoned house in the outskirt of Jakarta. The house has a nice and long yard which can be represented as a one-dimensional grid containing 1 \times N1×N cells. To beautify the house, Tali…
C. Dima and Salad time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Dima, Inna and Seryozha have gathered in a room. That's right, someone's got to go. To cheer Seryozha up and inspire him to…
B. Dima and To-do List time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You helped Dima to have a great weekend, but it's time to work. Naturally, Dima, as all other men who have girlfriends…
D. Dima and Bacteria time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Dima took up the biology of bacteria, as a result of his experiments, he invented k types of bacteria. Overall, there a…
One day Dima and Alex had an argument about the price and quality of laptops. Dima thinks that the more expensive a laptop is, the better it is. Alex disagrees. Alex thinks that there are two laptops, such that the price of the first laptop is less (…