UPC 6610 Restoring Road Network

无法找到来自源 nvlddmkm 的事件 ID 14 的描述 具体错误是: 无法找到来自源 nvlddmkm 的事件 ID 14 的描述。本地计算机上未安装引发此事件的组件,或者安装已损坏。可以安装或修复本地计算机上的组件。 出现这样错误的原因有很多了,有可能是硬件有可能是软件。由于我是刚配置的电脑,起初非常怀疑是自己组装的问题,折腾了好久,心态爆炸!!!先说我报这样错误的情况,以及解决办法,供后面人参考。 ... 阅读详情

 问题 C: Restoring Road Network

题目描述

In Takahashi Kingdom, which once existed, there are N cities, and some pairs of cities are connected bidirectionally by roads. The following are known about the road network:
People traveled between cities only through roads. It was possible to reach any city from any other city, via intermediate cities if necessary.
Different roads may have had different lengths, but all the lengths were positive integers.
Snuke the archeologist found a table with N rows and N columns, A, in the ruin of Takahashi Kingdom. He thought that it represented the shortest distances between the cities along the roads in the kingdom.
Determine whether there exists a road network such that for each u and v, the integer Au,v at the u-th row and v-th column of A is equal to the length of the shortest path from City u to City v. If such a network exist, find the shortest possible total length of the roads.

Constraints
1≤N≤300
If i≠j, 1≤Ai,j=Aj,i≤109.
Ai,i=0

输入

Input is given from Standard Input in the following format:
N
A1,1 A1,2 … A1,N
A2,1 A2,2 … A2,N
…
AN,1 AN,2 … AN,N

输出

If there exists no network that satisfies the condition, print -1. If it exists, print the shortest possible total length of the roads.

样例输入

3
0 1 3
1 0 2
3 2 0
样例输出
3
提示
The network below satisfies the condition:
City 1 and City 2 is connected by a road of length 1.
City 2 and City 3 is connected by a road of length 2.
City 3 and City 1 is not connected by a road.
#include<bits/stdc++.h>
using namespace std;
 
int n;
int a[305][305];
int dis[305][305];
int path[305][305];
 
void floyd()
{
    int i,j,k;
    for(k=0;k<n;k++)
    {
       for(i=0;i<n;i++)
       {
            for(j=0;j<n;j++)
            {
                if(dis[i][k]+dis[k][j]<=dis[i][j])
                {
                    dis[i][j]=dis[i][k]+dis[k][j];
                    path[i][j]++;
                }
            }
       }
    }
}
 
int main()
{
    while(~scanf("%d",&n))
    {
        memset(a,0,sizeof(a));
        memset(dis,0,sizeof(dis));
        memset(path,0,sizeof(path));
        for(int i=0;i<n;i++)
            for(int j=0;j<n;j++)
            {
                scanf("%d",&a[i][j]);
                dis[i][j]=a[i][j];
            }
        floyd();
        long long sum=0;
        int flag=0,f=0;
        for(int i=0;i<n&&flag==0;i++)
        {
            for(int j=0;j<n;j++)
            {
                if(path[i][j]==2)
                    sum+=a[i][j];
                if(a[i][j]!=dis[i][j])
                {
                    flag=1;
                    break;
                }
            }
        }
 
        if(flag==1)
        {
           printf("-1\n");
        }
        else
            printf("%lld\n",sum/2);
 
    }
    return 0;
}

 

基于深度强化学习技术优化无线网络中的资源分配(一)DQN部分代码 这是一个GitHub上的开源项目,链接:https://github.com/alexis-anzaldo/Deep-Reinforcement-Learning-for-resource-allocation-in-wireless-networks该项目旨在通过深度强化学习DQL技术优化无线网络中的资源分配,特别关注小型蜂窝和超密集无线蜂窝网络中的功率控制问题,主要目标是提高DRL模型的学习效率和网络吞吐量。 阅读详情

相关推荐

Linux中断子系统(二)—— 通用框架处理

1、数据结构分析 (1)中断描述符结构structirq_desc: 1)打开CONFIG_SPARSE_IRQ宏(中断编号不连续),中断描述符以radix- tree来组织,用户在初始化时进行动态分配,然后再插入radix-tree中; 2)关闭CONFIG_SPARSE_IRQ宏(中断编号连续),中断描述符以数组的 形式组织,并且已经分配好; 3)不管哪种形式,最终都可以通过linuxirq号来找到对应的中断描述符; (2)stru...

weixin_38428439的博客 4871

Restoring Road Network(类弗洛伊德)

                                    Restoring Road Network                                                                       时间限制: 1 Sec  内存限制: 128 MB                                             ...

月殇 293

5种隐藏代码到图片的实用技巧:从Notepad++到Linux命令全解析

本文详细解析了5种将代码或文本隐藏到图片中的实用数据隐写技巧。从Notepad++尾部追加、Windows命令行合并,到编辑图像元数据、使用十六进制编辑器,再到Linux的cat/dd命令,全面覆盖了从图形界面到命令行的工程化实践方法,帮助开发者和安全研究人员掌握隐蔽信息传输与存储的核心技术。

hh234的博客 353

C: Restoring Road Network(Floyd拓展应用)

问题 C: Restoring Road Network 时间限制: 1 Sec 内存限制: 128 MB 提交: 894 解决: 183 [提交] [状态] [讨论版] [命题人:admin] 题目描述 In Takahashi Kingdom, which once existed, there are N cities, and some pairs of cities are...

放纵不羁爱自由 251

IEEE论文接收后,收到Proof邮件别慌!手把手教你48小时内搞定校样(附详细截图)

本文详细解析了IEEE论文接收后Proof校样的全流程,从邮件关键信息解码到精准修改标注,提供48小时内高效完成校样的实战指南。涵盖登录技巧、文件验证、修改标注黄金法则及九宫格检查清单,帮助作者避免常见错误,确保论文顺利发表。

weixin_30652491的博客 563

STM32F407+HAL库+W5500实现TCP通讯 个人项目总结

推荐阅读此博客 cv即可成功首先需要一个可以进行串口调试的工程,方便进行调试。1.在W5500官网移植库文件重点是Ethernet这个文件夹将里面的 socket.c,socket.h,wizchip_conf.c,wizchip_conf.h,还有根据W5500文件夹里的w5500.c和w5500.h移植到自己的工程里面。然后再创建一个.c和.h文件 我的叫w5500_port_hal.c 和w5500_port_hal.h 记得将.h文件链接到工程里。

a234abr的博客 2247

Restoring Road Network (Floyed)

Problem Statement In Takahashi Kingdom, which once existed, there are N cities, and some pairs of cities are connected bidirectionally by roads. The following are known about the road network: People traveled between cities only through roads. It ...

C_Dreamy的博客 430

基于PyQt5和OpenCV的传统图像分割应用UI程序

主要功能包括:加载和显示图像应用多种图像分割算法调整算法参数保存处理结果。

Henry的博客 472

Restoring Road Network

Restoring Road Network 时间限制:1 Sec内存限制:128 MB In Takahashi Kingdom, which once existed, there are N cities, and some pairs of cities are connected bidirectionally by roads. The following are kn...

weixin_30768661的博客 152

Vue3 - 完美解决高德地图定位失败 Get ipLocation failed.Geolocation permission denied.(获取ipLocation失败。地理定位权限被拒绝。)

Get ipLocation failed.Geolocation permission denied.,vue3引入高德地图当前定位失败 ,vue3中使用高德地图定位报错,高德地图API用户定位失败,高德地图H5 定位失败报错排查和解决方案,微信公众号H5网页高德地图定位报错,谷歌浏览器-高德地图定位失败geolocation,getCurrentPosition 返回的 message报错,如何解决此问题,uniapp h5高德地图,微信、QQ等内置浏览器定位失败,高德地图实现实时用户位置定位,引入高德

🏆 前端领域优质创作者 4169

零基础学写《扫雷》游戏(Qt扫雷源码)

扫雷游戏是在windows系统中自带的游戏,他的游戏玩法其实很简单,20世纪初期电脑上没有啥游戏可以玩,所以扫雷游戏也算是当时是最常火爆的一个电脑游戏。以下文章详细介绍扫雷游戏的实现。实现语言为C++。

啊渊的专栏 1万+

6610: Restoring Road Network----反思

6610: Restoring Road Network 时间限制: 1 Sec  内存限制: 128 MB 提交: 908  解决: 189 [提交] [状态] [讨论版] [命题人:admin] 题目描述 In Takahashi Kingdom, which once existed, there are N cities, and some pairs of cities are c...

C/C++ 214

[QMT量化交易小白入门]-七、可转债双低策略Python代码详解与实战

本专栏主要是介绍QMT的基础用法,常见函数,写策略的方法,也会分享一些量化交易的思路,大概会写100篇左右。QMT的相关资料较少,在使用过程中不断的摸索,遇到了一些问题,记录下来和大家一起沟通,共同进步,自己淋过雨了,希望大家都有一把伞。

木头大左的博客 3847

[图论][最短路]Restoring Road Network

题目描述 In Takahashi Kingdom, which once existed, there are N cities, and some pairs of cities are connected bidirectionally by roads. The following are known about the road network:People traveled...

dingfei496705的博客 190

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

Contest1392 - 2018年第三阶段个人训练赛第七场. Restoring Road Network(最短路径 Floyd算法)

问题 C: Restoring Road Network 时间限制: 1 Sec  内存限制: 128 MB 提交: 790  解决: 161 [提交] [状态] [讨论版] [命题人:admin] 题目描述 In Takahashi Kingdom, which once existed, there are N cities, and some pairs of cities are c...

红鲤鱼与绿鲤鱼与驴 373

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

Atcoder - Restoring Road Network - floyd求最短总路径

问题Problem StatementIn Takahashi Kingdom, which once existed, there are N cities, and some pairs of cities are connected bidirectionally by roads. The following are known about the road network:People t

Daioo 随笔 729

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

Restoring Road Network 反证最短路

问题 C: Restoring Road Network 时间限制:1 Sec内存限制:128 MB 提交:438解决:89 [提交] [状态] [讨论版] [命题人:admin] 题目描述 In Takahashi Kingdom, which once existed, there are N cities, and some pairs...

weixin_30797027的博客 131

ARC 083D. 500 Restoring Road Network 最短路

题意:n个点的无向图, 告诉你矩阵a[i][j]:i-&gt;j的最短路径长度.1&lt;=n&lt;=300,问矩阵a是否合法.若a合法输出最小的边集之和.若存在a[i][j]&gt; a[i][k]+a[k][j] 则说明矛盾输出非法.a[i][j]如果存在一个中间点k 满足a[i][k]+a[k][j] = a[i][j] 那么(i,j)之间可以不用添加边.若不存在中间点k 为了使(i,j)...

noone0的博客 343

atcoder AtCoder Regular Contest 084 D - Small Multiple 最短路

传送门 思路:建立从1开始达到所有数的边,权值为位数和的差。最后dist[0]就是答案,代表最小的位数和能整除K。#include<bits/stdc++.h> using namespace std; typedef long long LL; const int MAXN = 1000005; struct node { int from, to, w; } G[MAXN]; int

DK 1058

问题 G: Trained?(石油大学,暑假集训)

问题 G: Trained? 时间限制: 1 Sec  内存限制: 128 MB 提交: 111  解决: 65 [提交] [状态] [讨论版] [命题人:admin] 题目描述 Takahashi wants to gain muscle, and decides to work out at AtCoder Gym. The exercise machine at the gym has...

guihaiyuan123的博客 394

@UPC 4897 @BAPC2017 Preliminaries : Envious Exponents(思维,二进制)

Envious Exponents 时间限制: 1 Sec  内存限制: 128 MB 提交: 252  解决: 37 [提交] [状态] [讨论版] [命题人:admin] 题目描述 Alice and Bob have an integer N. Alice and Bob are not happy with their integer. Last night they went to...

Sizaif's 小屋 322

ACM- Jungle Roads(第九天-图论)

Jungle Roads Time Limit:1000MS Memory Limit:10000K Total Submissions:19852 Accepted:9136 Description The Head Elder of the tropical island of Lagrishan h...

weixin_33982670的博客 119

UPC 第一套总结

G 题目描述 Takahashi wants to gain muscle, and decides to work out at AtCoder Gym. The exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up. These buttons are numbere...

eternityZZing的博客 720

图的基本操作和实现

图的基本操作与实现 (1)自选存储结构,输入含n个顶点(用字符表示顶点)和e条边的图G; (2)求每个顶点的度,输出结果; (3)指定任意顶点x为初始顶点,对图G作DFS遍历,输出DFS顶点序列(提示:使用一个栈实现DFS); (4)指定任意顶点x为初始顶点,对图G作BFS遍历,输出BFS顶点序列(提示:使用一个队列实现BFS); (5)输入顶点x,查找图G:若存在含...

JD_coder的博客 6215

CF-678B The Same Calendar (日历蔡勒公式)

The Same Calendar The girl Taylor has a beautiful calendar for the yeary. In the calendar all days are given with their days o...

JD_coder的博客 503

HDU-1873 看病要排队 (优先队列)

看病要排队 Time Limit: 3000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 15731Accepted Submission(s): 6692 Problem Des...

JD_coder的博客 458
上一篇: UPC 5502: 打地鼠游戏
下一篇: UPC 6615: Snuke Festival
进阶的萌新
博客等级 码龄9年 5粉丝 29原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值