Codeforces Round #428 (Div. 2) E - Mother of Dragons
2017-08-18 15:53
471 查看
题目链接: http://codeforces.com/contest/839/problem/E
题意: 将k滴液体,随意分配给这些N个点,这些点有些相连,有些不相连,当两个点有边相连的时候,他们能产生分配的液体乘积之和的价值,求最大价值。
看别人题解才懂这题,用最大团来做。
查来很多资料才终于懂了极大团和最大团的概念。
团:表示N 个点的集合,这N个点彼此两两连接,既有N(N-1)/2条边。
极大团: 表示无法是其他团的子团。
最大团:点最多的极大团。
如果是两个点,由(a+b)^2>=4ab,当a==b时等号成立,所以均分是最好的,然后发现取一个最大团后再均分是最佳方案。
题意: 将k滴液体,随意分配给这些N个点,这些点有些相连,有些不相连,当两个点有边相连的时候,他们能产生分配的液体乘积之和的价值,求最大价值。
看别人题解才懂这题,用最大团来做。
查来很多资料才终于懂了极大团和最大团的概念。
团:表示N 个点的集合,这N个点彼此两两连接,既有N(N-1)/2条边。
极大团: 表示无法是其他团的子团。
最大团:点最多的极大团。
如果是两个点,由(a+b)^2>=4ab,当a==b时等号成立,所以均分是最好的,然后发现取一个最大团后再均分是最佳方案。
#include<bits/stdc++.h> using namespace std; #define N 45 int n,i,j,k,mx ,g ,f ,ans; int dfs(int cur,int tot) { if(!cur) { if(tot>ans) return ans=tot,1; return 0; } for(int i=0,j,u,nxt;i<cur;i++) { if(cur-i+tot<=ans) return 0; u=f[tot][i],nxt=0; if(mx[u]+tot<=ans) return 0; for(j=i+1;j<cur;j++) if(g[u][f[tot][j]]) f[tot+1][nxt++]=f[tot][j]; if(dfs(nxt,tot+1)) return 1; } return 0; } int main() { double z; scanf("%d%lf",&n,&z); for(int i=0;i<n;i++) { for(int j=0;j<n;j++) { scanf("%d",&g[i][j]); } } for(i=n-1;~i;dfs(k,1),mx[i--]=ans) for(k=0,j=i+1;j<n;j++) if(g[i][j]) f[1][k++]=j; z/=ans; printf("%f",z*z*ans*(ans-1)/2); }
相关文章推荐
- Codeforces Round #428 (Div. 2) B.Game of the Rows(贪心+炒鸡多坑的模拟)
- Codeforces Round #428 (Div. 2) B. Game of the Rows (思维)
- Codeforces Round #428 (Div. 2) B. Game of the Rows(贪心)
- Codeforces Round #418 (Div. 2) C. An impassioned circulation of affection
- Codeforces Round #398(Div. 2)D. Cartons of milk【二分+暴力处理】
- Codeforces Round #437 (Div. 2 C. Ordering Pizza 贪心 only two types of pizza
- Codeforces Round #428 (Div. 2) C. Journey(dfs deep
- Codeforces Round #277.5 (Div. 2)C——Given Length and Sum of Digits...
- Codeforces Codeforces Round #432 (Div. 2 D ) Arpa and a list of numbers
- Codeforces Round #437 (Div. 2 C. Ordering Pizza 贪心 only two types of pizza
- Codeforces Round #428 (Div. 2) C. Journey(dfs deep
- Codeforces Round #302 (Div. 2) A. Set of Strings
- Codeforces Codeforces Round #432 (Div. 2 D ) Arpa and a list of numbers
- Codeforces Round #437 (Div. 2 C. Ordering Pizza 贪心 only two types of pizza
- Codeforces Round #428 (Div. 2) C. Journey(dfs deep
- Codeforces Round #249 (Div. 2)C Devu and Partitioning of the Array
- Codeforces Codeforces Round #432 (Div. 2 D ) Arpa and a list of numbers
- Codeforces Round #418 (Div. 2) C - An impassioned circulation of(尺取法)
- Codeforces Round #102 (Div. 2) ——B. Help Kingdom of Far Far Away 2
- Codeforces Round #437 (Div. 2 C. Ordering Pizza 贪心 only two types of pizza