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;
}




内容概要:本文为《科技类企业品牌传播白皮书》,系统阐述了新闻媒体发稿、自媒体博主种草与短视频矩阵覆盖三大核心传播策略,并结合“传声港”平台的AI工具与资源整合能力,提出适配科技企业的品牌传播解决方案。文章深入分析科技企业传播的特殊性,包括受众圈层化、技术复杂性与传播通俗性的矛盾、产品生命周期影响及2024-2025年传播新趋势,强调从“技术输出”向“价值引领”的战略升级。针对三种传播方式,分别从适用场景、操作流程、效果评估、成本效益、风险防控等方面提供详尽指南,并通过平台AI能力实现资源智能匹配、内容精准投放与全链路效果追踪,最终构建“信任—种草—曝光”三位一体的传播闭环。; 适合人群:科技类企业品牌与市场负责人、公关传播从业者、数字营销管理者及初创科技公司创始人;具备一定品牌传播基础,关注效果可量化与AI工具赋能的专业人士。; 使用场景及目标:①制定科技产品全生命周期的品牌传播策略;②优化媒体发稿、KOL合作与短视频运营的资源配置与ROI;③借助AI平台实现传播内容的精准触达、效果监测与风险控制;④提升品牌在技术可信度、用户信任与市场影响力方面的综合竞争力。; 阅读建议:建议结合传声港平台的实际工具模块(如AI选媒、达人匹配、数据驾驶舱)进行对照阅读,重点关注各阶段的标准化流程与数据指标基准,将理论策略与平台实操深度融合,推动品牌传播从经验驱动转向数据与工具双驱动。
【3D应力敏感度分析拓扑优化】【基于p-范数全局应力衡量的3D敏感度分析】基于伴随方法的有限元分析和p-范数应力敏感度分析(Matlab代码实现)内容概要:本文档围绕“基于p-范数全局应力衡量的3D应力敏感度分析”展开,介绍了一种结合伴随方法与有限元分析的拓扑优化技术,重点实现了3D结构在应力约束下的敏感度分析。文中详细阐述了p-范数应力聚合方法的理论基础及其在避免局部应力过高的优势,并通过Matlab代码实现完整的数值仿真流程,涵盖有限元建模、灵敏度计算、优化迭代等关键环节,适用于复杂三维结构的轻量化与高强度设计。; 适合人群:具备有限元分析基础、拓扑优化背景及Matlab编程能力的研究生、科研人员或从事结构设计的工程技术人员,尤其适合致力于力学仿真与优化算法开发的专业人士; 使用场景及目标:①应用于航空航天、机械制造、土木工程等领域中对结构强度和重量有高要求的设计优化;②帮助读者深入理解伴随法在应力约束优化中的应用,掌握p-范数法处理全局应力约束的技术细节;③为科研复现、论文写作及工程项目提供可运行的Matlab代码参考与算法验证平台; 阅读建议:建议读者结合文中提到的优化算法原理与Matlab代码同步调试,重点关注敏感度推导与有限元实现的衔接部分,同时推荐使用提供的网盘资源获取完整代码与测试案例,以提升学习效率与实践效果。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值