Poj 1789 Truck History
来源:互联网 发布:阿里天池大数据比赛 编辑:程序博客网 时间:2024/05/14 01:11
1Y
prim模板一套
完事大吉
#include<stdio.h>#include<algorithm>#include<string.h>#define INF ((int)1e9)#define N 2010using namespace std;int G[N][N];int low[N];char map[N][10];int cmp(int x,int y){ int len=strlen(map[x]); int i; int res=0; for(i=0;i<len;i++)if(map[x][i]!=map[y][i])res++; return res; }int main(){ int n; while(scanf("%d",&n)!=EOF&&n){ int i,j; for(i=1;i<=n;i++)scanf("%s",map[i]); for(i=1;i<=n;i++)for(j=1;j<=n;j++)G[i][j]=cmp(i,j); for(i=1;i<=n;i++)low[i]=G[1][i]; int res=0; for(i=2;i<=n;i++){ int in=INF,pmin; for(j=2;j<=n;j++)if(low[j]&&low[j]<in)in=low[j],pmin=j; low[pmin]=0;res+=in; for(j=2;j<=n;j++)low[j]=min(low[j],G[pmin][j]); } printf("The highest possible quality is 1/"); printf("%d.\n",res); } return 0; }
- POJ 1789 Truck History
- POJ 1789 Truck History
- POJ 1789 Truck History
- poj 1789 Truck History
- poj 1789 Truck History
- Poj 1789 Truck History
- poj 1789 Truck History
- poj 1789 Truck History
- poj 1789 Truck History
- poj 1789 Truck History
- POJ-1789-Truck History
- poj-1789-Truck History
- POJ 1789 Truck History
- poj 1789 Truck History
- POJ 1789 Truck History
- POJ 1789 Truck History
- POJ 1789 Truck History
- POJ 1789 Truck History
- 如何用Python写一个贪吃蛇AI
- ubuntu在右键添加 终端 命令
- 如何成为一名黑客[zz]
- 利用javascript将网站加入收藏夹
- android源码关联,android-support-v4.jar 源码关联
- Poj 1789 Truck History
- Hadoop 执行多个job
- hdu1593(find a way to escape)
- iOS开发那些事-移动平台架构设计
- org.hibernate.MappingException
- 人生中的第一篇博客
- Linux下安装jdk1.6
- myeclipse 9.1优化(eclipse与myeclipse编码设置)
- DNA Sorting