Truck History Poj 1789(Prim)

本文深入探讨了信息技术领域的核心技术和应用,包括但不限于前端开发、后端开发、移动开发、游戏开发、大数据开发等细分领域。从技术原理、实践案例到最新趋势,全方位解析信息技术在现代社会发展中的重要作用。
Truck History
Time Limit: 2000MS Memory Limit: 65536K
Total Submissions: 21311 Accepted: 8277

Description

Advanced Cargo Movement, Ltd. uses trucks of different types. Some trucks are used for vegetable delivery, other for furniture, or for bricks. The company has its own code describing each type of a truck. The code is simply a string of exactly seven lowercase letters (each letter on each position has a very special meaning but that is unimportant for this task). At the beginning of company's history, just a single truck type was used but later other types were derived from it, then from the new types another types were derived, and so on. 

Today, ACM is rich enough to pay historians to study its history. One thing historians tried to find out is so called derivation plan -- i.e. how the truck types were derived. They defined the distance of truck types as the number of positions with different letters in truck type codes. They also assumed that each truck type was derived from exactly one other truck type (except for the first truck type which was not derived from any other type). The quality of a derivation plan was then defined as 
1/Σ(to,td)d(to,td)

where the sum goes over all pairs of types in the derivation plan such that to is the original type and td the type derived from it and d(to,td) is the distance of the types. 
Since historians failed, you are to write a program to help them. Given the codes of truck types, your program should find the highest possible quality of a derivation plan. 

Input

The input consists of several test cases. Each test case begins with a line containing the number of truck types, N, 2 <= N <= 2 000. Each of the following N lines of input contains one truck type code (a string of seven lowercase letters). You may assume that the codes uniquely describe the trucks, i.e., no two of these N lines are the same. The input is terminated with zero at the place of number of truck types.

Output

For each test case, your program should output the text "The highest possible quality is 1/Q.", where 1/Q is the quality of the best derivation plan.

Sample Input

4
aaaaaaa
baaaaaa
abaaaaa
aabaaaa
0

Sample Output

The highest possible quality is 1/3.



感觉这道题难就难在建图上。我居然又将 Map[i][j]=Map[j][i]=*写成了Map[i][j]=*,在经过大脑0.1秒的思考并不是一定是先输入的是衍生根Q Q。


#include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

#define INF 0x3f3f3f3f

using namespace std;

char s[2001][8];
int Map[2001][2001],ans,vis[2001],dis[2001],n,z;
void prim()
{
    int i,j,k,pos,ma;
    memset(vis,0,sizeof(vis));
    for(i=1; i<n; i++)
        dis[i]=Map[0][i];
    vis[0]=1;
    for(i=0; i<n-1; i++)
    {
        ma=INF;
        for(j=1; j<n; j++)
        {
            if(dis[j]<ma&&!vis[j])
            {
                ma=dis[j];
                pos=j;
            }
        }
        z+=ma;
        vis[pos]=1;
        for(j=1; j<n; j++)
        {
            if( dis[ j ]>Map[pos][j] &&!vis[j])
            {
                dis[j]=Map[pos][j];
            }
        }
    }
    printf("The highest possible quality is 1/%d.\n",z);
}
int main()
{
    int i,j,k,m,mi;
    ios::sync_with_stdio(false);
    while(cin>>n&&n)
    {
        z=0;
        for(i=0; i<n; i++)
            cin>>s[i];
        memset(Map,0,sizeof(Map));
        for(i=0; i<n; i++)
        {
            for(j=0; j<n; j++)
            if(i!=j)
               Map[j][i]=Map[i][j]=INF;
            else
               Map[i][j]=0;
        }
        for(i=0; i<n; i++)
        {
            ans=0;
            for(j=0; j<n; j++)
            {
                ans=0;
                for(k=0; k<7; k++)
                {
                    if(s[i][k]!=s[j][k])
                    {
                        ans++;
                    }
                }
                if(Map[i][j]>ans)
                {
                    Map[i][j]=ans;
                    Map[j][i]=ans;
                }
                //    cout<<Map[i][j]<<endl;
            }
        }
        prim();
    }
    return 0;
}




当前,全球经济格局深刻调整,数字化浪潮席卷各行各业,智能物流作为现代物流发展的必然趋势和关键支撑,正迎来前所未有的发展机遇。以人工智能、物联网、大数据、云计算、区块链等前沿信息技术的快速迭代与深度融合为驱动,智能物流不再是传统物流的简单技术叠加,而是正在经历一场从自动化向智能化、从被动响应向主动预测、从信息孤岛向全面互联的深刻变革。展望2025年,智能物流系统将不再局限于提升效率、降低成本的基本目标,而是要构建一个感知更全面、决策更精准、执行更高效、协同更顺畅的智慧运行体系。这要求我们必须超越传统思维定式,以系统化、前瞻性的视角,全面规划和实施智能物流系统的建设。本实施方案正是基于对行业发展趋势的深刻洞察和对未来需求的精准把握而制定。我们的核心目标在于:通过构建一个集成了先进感知技术、大数据分析引擎、智能决策算法和高效协同平台的综合智能物流系统,实现物流全链路的可视化、透明化和智能化管理。这不仅是技术层面的革新,更是管理模式和服务能力的全面提升。本方案旨在明确系统建设的战略方向、关键任务、技术路径和实施步骤,确保通过系统化部署,有效应对日益复杂的供应链环境,提升整体物流韧性,优化资源配置效率,降低运营成本,并最终为客户创造更卓越的价值体验。我们致力于通过本方案的实施,引领智能物流迈向更高水平,为构建现代化经济体系、推动高质量发展提供强有力的物流保障。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值