[cerc2017J]Justified Jungle】的更多相关文章

题目大意:删去k条边,树变为相等个点的连通分量,求所有正整数k. 解题关键:树dp,不必求因子. #include<bits/stdc++.h> using namespace std; typedef long long ll; #define maxn 1000006 int head[maxn],cnt,siz[maxn],v[maxn],n; struct edge{ int to,nxt; }e[maxn<<]; void add_edge(int u,int v){ e…
题意: 给出一棵树,删掉其中一些边,要求生成的每个子树节点数一样.输出所有可以删掉的边数. 题解: 以节点1为根,预处理每个子树的大小.对于每个n的因数x,还需满足子树为他倍数的点够n/x个,那么删的边数就为n/x-1. #include <bits/stdc++.h> using namespace std; ; int n; int u, v; int sz[N], vis[N]; int tot; ], nxt[N<<]; vector<int> ans; voi…
A. Assignment Algorithm 按题意模拟即可. #include<stdio.h> #include<iostream> #include<string.h> #include<string> #include<ctype.h> #include<math.h> #include<set> #include<map> #include<vector> #include<que…
2017 CERC Problem A:Assignment Algorithm 题目描述:按照规则安排在飞机上的座位. solution 模拟. 时间复杂度:\(O(nm)\) Problem B:Buffalo Barricades 题目描述:将二维平面划分为一个个单位格,在平面上有一些被标记的格子.将\(x,y\)轴当成是围栏,现在以此给出一些坐标,每次从那个坐标出发向\(x, y\)轴建围栏,并输出新围栏围住的被标记格子数. solution 待解决. C:Cumulative Code…
A:Assignment Algorithm #include <bits/stdc++.h> using namespace std; ][]; ][],n,m,ans=,A,B,l=,r=,ls=,rs=; ]={,,,,,,,,,,,}; map<int,int>v; void init(){ v[]=;v[]=; v[]=;v[]=; v[]=;v[]=; v[]=;v[]=; } ,vis=; struct node{ int val,dis,id;//座位数,记录过道距…
poj   1251  Jungle Roads  (最小生成树) Link: http://poj.org/problem?id=1251 Jungle Roads Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 23507   Accepted: 11012 Description The Head Elder of the tropical island of Lagrishan has a problem. A b…
Jungle Roads Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 7096    Accepted Submission(s): 5185 Problem Description The Head Elder of the tropical island of Lagrishan has a problem. A burst of…
Description The Head Elder of the tropical island of Lagrishan has a problem. A burst of foreign aid money was spent on extra roads between villages some years ago. But the jungle overtakes roads relentlessly, so the large road network is too expensi…
D - Jungle Roads Time Limit:1000MS     Memory Limit:10000KB     64bit IO Format:%I64d & %I64u Submit Status Practice POJ 1251 Description The Head Elder of the tropical island of Lagrishan has a problem. A burst of foreign aid money was spent on extr…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1301 The Head Elder of the tropical island of Lagrishan has a problem. A burst of foreign aid money was spent on extra roads between villages some years ago. But the jungle overtakes roads relentlessly,…