热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

优化后的标题:校园互联新方案:10397连接教育未来

Problem E Connect the Campus Input: standard input Output: standard output Time Limit: 2 seconds Ma
Problem E

Connect the Campus

Input: standard input

Output: standard output

Time Limit: 2 seconds



Many new buildings are under construction on the campus of the University of Waterloo.

许多新的建筑物在建造在滑铁卢大学的校园。

The university has hired bricklayers, electricians, plumbers, and a computer programmer.

学校聘请了砌砖工,电工,水管工,和一个计算机程序员。

A computer programmer? Yes, you have been hired to ensure that each building is connected to every other building (directly or indirectly) through the campus network of communication cables.

一个计算机程序员?是的,你被雇佣来确保每个建筑连接到每个建筑(直接或间接)通过通讯电缆的校园网络。

We will treat each building as a point specified by an x-coordinate and a y-coordinate.

我们将把每一个建筑物作为一个点的X坐标和y坐标指定。

Each communication cable connects exactly two buildings, following a straight line between the buildings.

每个通信电缆连接两个建筑物,在建筑物之间的一条直线。

Information travels along a cable in both directions.

信息沿着两个方向的电缆。

Cables can freely cross each other, but they are only connected together at their endpoints (at buildings).

电缆可以自由地相互交叉,但他们只连接在一起,在它们的端点(建筑物)。

You have been given a campus map which shows the locations of all buildings and existing communication cables.

你已经给了一个校园地图,显示了所有建筑物和现有的通信电缆的位置。

You must not alter the existing cables.

你不能改变现有的电缆。

Determine where to install new communication cables so that all buildings are connected.

确定要安装新的通信电缆,连接所有大楼。

Of course, the university wants you to minimize the amount of new cable that you use.

当然,大学要你减少你使用新的电缆的数量。

【最小生成树 Prim/Kruskal&并查集】



Fig: University of Waterloo Campus 图:滑铁卢大学校园



 



Input



The input file describes several test case.  The description of each test case is given below:

输入文件描述了几个测试用例。每个测试案例的描述如下:

The first line of each test case contains the number of buildings N (1<&#61;N<&#61;750). The buildings are labeled from 1 to N.

每个测试案例的第一行包含建筑的数量N&#xff08;1≤n≤750&#xff09;。建筑标记从1到N&#xff0c;

The next N lines give the x and y coordinates of the buildings.

以下N行给X和Y坐标的建筑物。

These coordinates are integers with absolute values at most 10000.

这些坐标是绝对值的整数 最多10000

No two buildings occupy the same point.

没有两个建筑占据同一点。

After that there is a line containing the number of existing cables M (0 <&#61; M <&#61; 1000) followed by M lines describing the existing cables.

之后有一行包含现有的电缆的数量&#xff08;0≤m≤1000&#xff09;随后的M行描述现有的电缆。

Each cable is represented by two integers: the building numbers which are directly connected by the cable.

每个电缆是由两个整数表示&#xff1a;这是由电缆直接连接的门牌号码。

There is at most one cable directly connecting each pair of buildings.

至多有一个电缆直接连接每对建筑物。

Output



For each set of input, output in a single line the total length of the new cables that you plan to use, rounded to two decimal places.

对每一组输入&#xff0c;输出一行新的电缆总长度&#xff0c;你计划使用&#xff0c;圆形到两位小数。




推荐阅读
  • 本文将介绍如何编写一些有趣的VBScript脚本,这些脚本可以在朋友之间进行无害的恶作剧。通过简单的代码示例,帮助您了解VBScript的基本语法和功能。 ... [详细]
  • 本文详细介绍了如何在Linux系统上安装和配置Smokeping,以实现对网络链路质量的实时监控。通过详细的步骤和必要的依赖包安装,确保用户能够顺利完成部署并优化其网络性能监控。 ... [详细]
  • 本文详细介绍了 Dockerfile 的编写方法及其在网络配置中的应用,涵盖基础指令、镜像构建与发布流程,并深入探讨了 Docker 的默认网络、容器互联及自定义网络的实现。 ... [详细]
  • 本文详细介绍如何使用Python进行配置文件的读写操作,涵盖常见的配置文件格式(如INI、JSON、TOML和YAML),并提供具体的代码示例。 ... [详细]
  • 本文介绍了如何使用JQuery实现省市二级联动和表单验证。首先,通过change事件监听用户选择的省份,并动态加载对应的城市列表。其次,详细讲解了使用Validation插件进行表单验证的方法,包括内置规则、自定义规则及实时验证功能。 ... [详细]
  • 扫描线三巨头 hdu1928hdu 1255  hdu 1542 [POJ 1151]
    学习链接:http:blog.csdn.netlwt36articledetails48908031学习扫描线主要学习的是一种扫描的思想,后期可以求解很 ... [详细]
  • 本文介绍如何使用阿里云的fastjson库解析包含时间戳、IP地址和参数等信息的JSON格式文本,并进行数据处理和保存。 ... [详细]
  • MySQL 数据库迁移指南:从本地到远程及磁盘间迁移
    本文详细介绍了如何在不同场景下进行 MySQL 数据库的迁移,包括从一个硬盘迁移到另一个硬盘、从一台计算机迁移到另一台计算机,以及解决迁移过程中可能遇到的问题。 ... [详细]
  • 随着网络安全威胁的不断演变,电子邮件系统成为攻击者频繁利用的目标。本文详细探讨了电子邮件系统中的常见漏洞及其潜在风险,并提供了专业的防护建议。 ... [详细]
  • 本题探讨如何通过最大流算法解决农场排水系统的设计问题。题目要求计算从水源点到汇合点的最大水流速率,使用经典的EK(Edmonds-Karp)和Dinic算法进行求解。 ... [详细]
  • 本文介绍了如何使用 Spring Boot DevTools 实现应用程序在开发过程中自动重启。这一特性显著提高了开发效率,特别是在集成开发环境(IDE)中工作时,能够提供快速的反馈循环。默认情况下,DevTools 会监控类路径上的文件变化,并根据需要触发应用重启。 ... [详细]
  • 本文将介绍如何使用 Go 语言编写和运行一个简单的“Hello, World!”程序。内容涵盖开发环境配置、代码结构解析及执行步骤。 ... [详细]
  • 1:有如下一段程序:packagea.b.c;publicclassTest{privatestaticinti0;publicintgetNext(){return ... [详细]
  • ImmutableX Poised to Pioneer Web3 Gaming Revolution
    ImmutableX is set to spearhead the evolution of Web3 gaming, with its innovative technologies and strategic partnerships driving significant advancements in the industry. ... [详细]
  • 2023年京东Android面试真题解析与经验分享
    本文由一位拥有6年Android开发经验的工程师撰写,详细解析了京东面试中常见的技术问题。涵盖引用传递、Handler机制、ListView优化、多线程控制及ANR处理等核心知识点。 ... [详细]
author-avatar
瑩影貓貓05
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有