#include<iostream>
#include<cstring>
#include<algorithm>
#include<stdio.h>
using namespace std;
const int INF=0x3f3f3f3f;
const int N=;
int n;
int p[N];
char str[N][];
int num=;
struct edge{
int a,b;
int w;
}e[N*N];
bool cmp(edge a,edge b)
{
return a.w<b.w;
}
int find(int x)
{
if(p[x]!=x)
p[x]=find(p[x]);
return p[x];
}
int dist(int i,int j)
{
int w=;
for(int k=;k<;k++)
if(str[i][k]!=str[j][k])
w++;
return w;
}
int kruskal()
{
sort(e,e+num,cmp);
int sum=;
for(int i=;i<num;i++)
{
int a=find(e[i].a);
int b=find(e[i].b);
int w=e[i].w;
if(a!=b)
{
p[a]=b;
sum+=w;
}
}
return sum;
}
int main()
{
while(cin>>n&&n)
{
num=;
for(int i=;i<=n;i++)
p[i]=i;
for(int i=;i<=n;i++)
cin>>str[i];
for(int i=;i<=n-;i++)
for(int j=i+;j<=n;j++)
e[num++]={i,j,dist(i,j)};
cout<<"The highest possible quality is 1/"<<kruskal()<<'.'<<endl;
}
}

最新文章

  1. 【BZOJ2223/3524】[Coci 2009]PATULJCI
  2. BizTalk 中使用 WCF-OracleDB adapter
  3. Java RESTful Web Service相关概念
  4. POJ3687——Labeling Balls(反向建图+拓扑排序)
  5. 汉企C#面向对象——继承
  6. ADO.NET(一) 空间 ADO.NET结构 命名空间(车延禄) System.Data—— 所有的一般数据访问类 S(转载)
  7. sql常用语句汇总
  8. Redis sentinel 哨兵模式集群方案配置
  9. Docker容器如何互联
  10. Vivado怎么使用In system debug(类似于chipscope的东西)
  11. xpath 笔记
  12. 得到一个文件夹中所有文件的名称的几个方法(命令指示符, C++, python)
  13. Linux学习笔记之五————Linux常用命令之用户、权限管理
  14. 【QT】对话框打开图像并用QPixmap显示
  15. 学习笔记之Lazy evaluation
  16. wkhtmtopdf--高分辨率HTML转PDF(二)
  17. 记录pytorch的几个问题
  18. Android Emoji兼容包使用详解
  19. 实战入侵(突破FCK+安全狗上传)
  20. spark第十篇:Spark与Kafka整合

热门文章

  1. 【WPF学习】第四十五章 可视化对象
  2. Yandex Big Data Essentials Week1 Unix Command Line Interface File Content exploration
  3. Python3(十一) 原生爬虫
  4. Day6前端学习之路——布局
  5. iOS开发基础--C语言简述(一)
  6. leetcode--js--Two Sum
  7. C#建立自己的测试用例系统
  8. Java自学-多线程 线程安全的类
  9. Java中,一个存在了十几年的bug...
  10. const与指针、引用