[Arc083D/At3535] 有 \(N\) 个城市,城市与城市之间用长度为整数的无向道路连接. 现有一考古学家找到了一张 \(N×N\) 的表 \(A\) ,这张表代表了这 \(N\) 座城市两两之间的最短路.即表中的第 \(u\) 行第 \(v\)列的值代表了从城市 \(u\)到\(v\)的最短路长度. 问能否根据这张表,求出高桥王国的最小道路长度总和. ---------- 考虑到原图中的边一定就在这个最短路矩阵中,我们只需要保留其中的一些,让它们"表示"出其它就可以了 那么…
D - Restoring Road Network Time limit : 2sec / Memory limit : 256MB Score : 500 points 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…
问题 C: Restoring Road Network 时间限制: 1 Sec  内存限制: 128 MB提交: 731  解决: 149[提交] [状态] [讨论版] [命题人:admin] 题目描述 In Takahashi Kingdom, which once existed, there are N cities, and some pairs of cities are connected bidirectionally by roads. The following are kn…
个人心得:看懂题目花费了不少时间,后面实现确实时间有点仓促了,只是简单的做出了判断是否为真假的情况, 后面看了题解发现其实在判断时候其实能够一起解决的,算了,基础比较差还是慢慢的来吧. 题意概述: 就是给定一个N阶方阵,规定Auv,为u到v的最短路径,若给出的数据存在其他通路少于此时的值则不存在即为假, 解决方法就是利用Floyd算法进行单源最短路的判断,只要后面的矩阵与原来的不相符就是假的.真的的时候,是要求 存在的最短总路程使得矩阵的数成立,我画了下就是只要存在从其他城市能够转到目的地的时候…
题意 有一张无向带权连通图(点数<=300),给出任意两点i,j之间的最短路长度dis[i][j].问是否存在一张这样的无向图.如果不存在输出-1.如果存在输出所有这样的无向图中边权和最小的一张的边权和. 分析 如果存在i,j,k(i,j,k互不相同)使得dis[i][k]+dis[k][j]<dis[i][j]那么一定不存在.否则一定存在. 对于i,j(i!=j),如果存在第三个点k使得dis[i][k]+dis[k][j]=dis[i][j],那么为了总的边权和最小,i和j必然没有连边,i…
[算法]图论,最短路? [题意]原图为无向连通图,现给定原图的最短路矩阵,求原图最小边权和,n<=300. [题解]要求最小边权和下,原图的所有边一定是所连两端点的最短路. 那么现在将所有最短路作为边加入原图,考虑删边. 对于(u,v),若存在点w使得(u,v)=(u,w)+(w,v),则(u,v)可以删去.(btw,若是>则无解) 复杂度O(n^3). #include<cstdio> #include<cstring> #include<cctype>…
[链接]h在这里写链接 [题意] 给你任意两点之间的最短路. 让你求出原图. 或者输出原图不存在. 输出原图的边长总和的最小值. [题解] floyd算法. 先在原有的矩阵上. 做一遍floyd. 如果还能扩展. 也即存在w[i][j] > w[i][k]+w[k][j]; 则无解. 否则. 先把所有w[i][j]加上(i<j),记为ans; 也即先在任意两点之间都连一条边.边的长度对应了两点之间最短路. 然后考虑什么时候可以减少一条边. 可以在做floyd的时候. 如果出现w[i][j] =…
Original article published here, Posted on March 18, 2009 by lidar A positive feedback loop is beginning to develop with readers submitting information. There is a LIDAR textbook that I just became aware of and 2 new digital documentation conferences…
http://acm.hdu.edu.cn/showproblem.php?pid=1596 这道题目与杭电2544最短路的思想是一样的.仅仅只是是把+改成了*,输入输出有些不一样而已. find the safest road Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 6985    Accepted Submission(s…
http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=45523 有一个国王想在首都与各个城市之间修建公路,但是他的预算太高,所以必须要降低预算. 为了降低预算,必须要有新计划,新计划必须满足每两个城市都连通,首都和城市的最短距离不会改变两个条件. 输入N各城市,首都标号为1,m条路,m行每行四个数,u,v,d,c;表示u跟v联通,并且距离为d,修路花费为c. 输出最小花费. 首先从首都开始求出到每个城市的最短路,然后再满足最短距…
分析:(官方题解) 首先考虑暴力,显然可以直接每次O(n^2) ​的连边,最后跑一次分层图最短路就行了. 然后我们考虑优化一下这个连边的过程 ,因为都是区间上的操作,所以能够很明显的想到利用线段树来维护整个图, 连边时候找到对应区间,把线段树的节点之间连边.这样可以大大缩减边的规模,然后再跑分层图最短路就可以了. 但是这样建图,每一次加边都要在O(logn)个线段树节点上加边,虽然跑的非常快,但是复杂度仍然是不科学的. 为了解决边的规模的问题,开两棵线段树,连边时候可以新建一个中间节点,在对应区…
find the safest road Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 9122    Accepted Submission(s): 3213 Problem Description XX星球有很多城市,每个城市之间有一条或多条飞行通道,但是并不是所有的路都是很安全的,每一条路有一个安全系数s,s是在 0 和 1 间…
题意: 给出一个有向图,求每条边有多少次作为最短路上的边(任意的起始点). 范围:n <= 1500, m <= 5005 分析: 一个比较容易想到的思路:以每个点作为起点,做一次SPFA,记f[i]表示从点S到达点i的最短路数,g[i]表示从点i到达点T的最短路数. 那么对于任意一条边,答案就是∑f[u]*g[v] 剩下的问题就是f.g怎么求. f必须从前面的递推过来,如果前面的没有递推完,那么就不能递推当前点,需要记录每个点可以从多少个点递推过来,这个一次dfs就可以完成. g可以记忆化搜…
题面 分析: 很多人都给出了做法,在这里不赘述.大概就是先把桥找出来,然后边双缩点,最后统计新图上的度数.因为缩点后为一棵树,所以度数为1(即为叶子)的点的数目+1再除以2下取整就是答案. 这里主要证明一下为什么是对的. 表达式:\[答案=\lfloor\frac{叶子数+1}{2}\rfloor\] 证明:考虑一棵树中,我们找出带权重心,使得重心下每个子节点的叶子节点数尽量的平均(具体实现不讲了),那么在这棵尽量平均的树上,我们每次取两个根节点下子树不同的叶子节点连边,比如说最左边连最右边,左…
贵有恒,何必三更起五更眠:最无益,莫过一日曝十日寒. 问题 C: Restoring Road Network 问题 C: Restoring Road Network 时间限制: 1 Sec  内存限制: 128 MB提交: 896  解决: 184[提交] [状态] [讨论版] [命题人:admin] 题目描述 In Takahashi Kingdom, which once existed, there are N cities, and some pairs of cities are…
C - Sugar Water 计算一下可以达到水是多少,可以到达的糖是多少 枚举水,然后加最多能加的糖,是\(min(F - i *100,E * 100)\),计算密度,和前一个比较就行 #include <bits/stdc++.h> #define fi first #define se second #define pii pair<int,int> #define mp make_pair #define pb push_back #define space putch…
C - Sugar Water Time limit : 3sec / Memory limit : 256MB Score : 300 points Problem Statement Snuke is making sugar water in a beaker. Initially, the beaker is empty. Snuke can perform the following four types of operations any number of times. He ma…
Caravans Time limit: 1.0 secondMemory limit: 64 MB Student Ilya often skips his classes at the university. His friends criticize him for this, but they don't know that Ilya spends this time not watching TV serials or listening to music. He creates a…
题目链接: http://codeforces.com/problemset/problem/208/C C. Police Station time limit per test:2 secondsmemory limit per test:256 megabytes 问题描述 The Berland road network consists of n cities and of m bidirectional roads. The cities are numbered from 1 to…
A. The Two Routes time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output In Absurdistan, there are n towns (numbered 1 through n) and m bidirectional railways. There is also an absurdly simple ro…
Destroying Roads time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output In some country there are exactly n cities and m bidirectional roads connecting the cities. Cities are numbered with intege…
题目链接: 题目 D. Destroying Roads time limit per test 2 seconds memory limit per test 256 megabytes inputstandard input outputstandard output 问题描述 In some country there are exactly n cities and m bidirectional roads connecting the cities. Cities are numbe…
Description In Absurdistan, there are n towns (numbered 1 through n) and m bidirectional railways. There is also an absurdly simple road network — for each pair of different towns x and y, there is a bidirectional road between towns x and yif and onl…
D - Destroying Roads Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/544/problem/D Description In some country there are exactly n cities and m bidirectional roads connecting the cities. Cities are numbered with integers f…
D. Destroying Roads 题目大意: In some country there are exactly n cities and m bidirectional roads connecting the cities. Cities are numbered with integers from 1 to n. If cities a and b are connected by a road, then in an hour you can go along this road…
Ikki's Story I - Road Reconstruction Time Limit: 2000MS   Memory Limit: 131072K Total Submissions: 7659   Accepted: 2215 Description Ikki is the king of a small country – Phoenix, Phoenix is so small that there is only one city that is responsible fo…
Ikki's Story I - Road Reconstruction Time Limit: 2000MS   Memory Limit: 131072K Total Submissions: 7971   Accepted: 2294 Description Ikki is the king of a small country – Phoenix, Phoenix is so small that there is only one city that is responsible fo…
Reverse a Road II Time Limit: 10000ms, Special Time Limit:25000ms, Memory Limit:65536KB Total submit users: 10, Accepted users: 6 Problem 13411 : No special judgement Problem description JAG Kingdom is a strange kingdom such that its N cities are con…
一个针对出租车司机有效花费的推荐系统 摘要 GPS技术和新形式的城市地理学改变了手机服务的形式.比如说,丰富的出租车GPS轨迹使得出做租车领域有新方法.事实上,最近很多工作是在使用出租车GPS轨迹数据来开发手机推荐系统.这些系统可以推荐一系列的载客点,为了使得在最短的驾驶距离里最大可能地找到一个乘客.然而,在现实世界中,出租车的收入和有效的驾驶时间息息相关.换句话说,对一个出租车司机来说,在找到一个乘客前知道一个确切地驾驶路径来缩短驾驶时间更加重要.最后,在本文中,我们提出了开发一个收益比高的推…
Description through n) and m bidirectional railways. There is also an absurdly simple road network — for each pair of different towns x and y, there is a bidirectional road between towns x and yif and only if there is no railway between them. Travell…