dp相关
zstu_zy
博主比较水,喜欢打codeforces,希望可以一起交流
展开
-
Codeforces Round #382 (Div. 2) E. Ostap and Tree
题意,有一个树,可以在树上的节点上填黑色,问,保证每个节点距离问k以内都存在黑色节点的方案数。dp[i][j]代表对于第i个节点当距离他距离为j的节点为黑色可取的方案数,因为要考虑分叉的情况,可能叙述与前面的解释不符合(我语文不好怪我喽)。先把树转化成有根树,对于一个点v,如果它只有一个儿子u,那么dp[v][i] = dp[u][i-1];如果不止一个儿子。那么先按上述方案处理。然后原创 2016-12-02 16:28:13 · 587 阅读 · 0 评论 -
Codeforces Round #257 (Div. 1) D. Jzzhu and Numbers
D. Jzzhu and Numbers time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Jzzhu have n non-negative integers a1, a2, …, an. We will call a seq...原创 2018-08-17 12:35:46 · 274 阅读 · 0 评论 -
hdu 6357 Hills And Valleys
Problem Description Tauren has an integer sequence A of length n (1-based). He wants you to invert an interval [l,r] (1≤l≤r≤n) of A (i.e. replace Al,Al+1,⋯,Ar with Ar,Ar−1,⋯,Al) to maximize the lengt...原创 2018-08-07 10:40:16 · 265 阅读 · 0 评论 -
Game Rooms HDU - 5550
Your company has just constructed a new skyscraper, but you just noticed a terrible problem: there is only space to put one game room on each floor! The game rooms have not been furnished yet, so you ...原创 2018-07-16 09:55:29 · 202 阅读 · 0 评论 -
hdu 5534 Partial Tree 完全背包
In mathematics, and more specifically in graph theory, a tree is an undirected graph in which any two nodes are connected by exactly one path. In other words, any connected graph without simple cycles...原创 2018-07-12 10:58:59 · 143 阅读 · 0 评论 -
Codeforces Round #445 (Div. 1, based on Technocup 2018 Elimination Round 3) E. Mod Mod Mod
E. Mod Mod Mod time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output You are given a sequence of integers a1, a2, …, an. Let , and for 1 ≤ i <原创 2017-12-01 17:11:00 · 394 阅读 · 0 评论 -
Educational Codeforces Round 32 F. Connecting Vertices
F. Connecting Vertices time limit per test4 seconds memory limit per test256 megabytes inputstandard input outputstandard output There are n points marked on the plane. The points are situated in原创 2017-11-16 15:55:11 · 321 阅读 · 0 评论 -
Codeforces Round #448 (Div. 2) C. Square Subsets
C. Square Subsets time limit per test4 seconds memory limit per test256 megabytes inputstandard input outputstandard output Petya was late for the lesson too. The teacher gave him an additional ta原创 2017-11-27 12:14:11 · 889 阅读 · 0 评论 -
Codeforces Round #448 (Div. 2) D. String Mark
D. String Mark time limit per test4 seconds memory limit per test256 megabytes inputstandard input outputstandard output At the Byteland State University marks are strings of the same length. Mark原创 2017-11-27 12:27:00 · 131 阅读 · 0 评论 -
hdu 6241
Color a TreeTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 385 Accepted Submission(s): 86Problem Description Bob intends to color the no原创 2017-11-28 10:55:44 · 484 阅读 · 0 评论 -
Codeforces Round #396 (Div. 2) E. Mahmoud and a xor trip
将数拆分成二进制形式,对于节点i,用cnt[x][i][1]和cnt[x][i][0]记录以x为根节点的所有路径权值在第i位上为0和为1的个数。那么以节点i为根的树上的所有节点相互之间的路径和就可以通过cnt数组进行dp,将子树v合并的操作是通过ans[i][1] += cnt[x][i][1]*cnt[v][i][0]+cnt[x][i][0]*cnt[v][i][1]进行转移。#include原创 2017-07-02 16:30:17 · 190 阅读 · 0 评论 -
hdu 6416 dp
Rikka with Seam Problem Description Seam carving is a novel algorithm for resizing images while maintaining as much information as possible from the source image.Now, Rikka is going to use seam ca...原创 2018-08-21 15:01:16 · 472 阅读 · 0 评论