[Codeforces440D]Berland Federalization】的更多相关文章

Problem 给你一棵树,最少删掉哪些边,能使得余下的至少有1个大小刚好为k的残树. 1 ≤ k ≤ n ≤ 400 Solution 用f[i][j]表示以i为根有j个节点的最少删边数量 因为此题要输出删除的边 v[i][j]表示以i为根删掉j个节点需要删去的边对应的(点u,该u点还需要删去的边数量) Notice 因为要输出方案,所以比较复杂 Code #include<cmath> #include<vector> #include<cstdio> #inclu…
题目大意: 给你一棵树,你可以删掉一些边,使得分除去的子树中至少有一棵大小为k. 问最少删去多少边,以及删边的具体方案. 思路: 树形DP. f[i][j]表示以i为根,子树中去掉j个点最少要删边的数量: v[i][j]表示其具体方案. 然后对每个点跑一下背包. 状态转移方程f[x][k+j]=min{f[x][k]+f[y][j]|y为x子结点}. 注意y的不同状态不能同时对x的同一个状态产生影响,所以转移的时候必须把数组复制一遍,将原数组和转移过后的数组隔离开来. v的转移只需要把v[x][…
题目链接:http://codeforces.com/contest/440/problem/D D. Berland Federalization   Recently, Berland faces federalization requests more and more often. The proponents propose to divide the country into separate states. Moreover, they demand that there is a…
The map of Berland is a rectangle of the size n × m, which consists of cells of size 1 × 1. Each cell is either land or water. The map is surrounded by the ocean. Lakes are the maximal regions of water cells, connected by sides, which are not connect…
D. Lakes in Berland time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The map of Berland is a rectangle of the size n × m, which consists of cells of size 1 × 1. Each cell is either land or…
Description The map of Berland is a rectangle of the size n × m, which consists of cells of size 1 × 1. Each cell is either land or water. The map is surrounded by the ocean. Lakes are the maximal regions of water cells, connected by sides, which are…
题目链接: 传送门 Berland Bingo time limit per test:1 second     memory limit per test:256 megabytes Description Lately, a national version of a bingo game has become very popular in Berland. There are n players playing the game, each player has a card with…
B. Berland National LibraryTime Limit: 2 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/567/problem/B Description Berland National Library has recently been built in the capital of Berland. In addition, in the library you can take any of…
D. Lakes in Berland time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The map of Berland is a rectangle of the size n × m, which consists of cells of size 1 × 1. Each cell is either land or…
D. Lakes in Berland time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The map of Berland is a rectangle of the size n × m, which consists of cells of size 1 × 1. Each cell is either land or…