1111 Online Map (30分)

本文介绍了一种算法,该算法能够找到从起点到终点的最短路径和最快路径。通过使用Dijkstra算法,我们可以在考虑距离和时间两种度量标准的情况下,为用户提供两个推荐路径。文章详细解释了如何处理街道的双向性和一维性,以及如何在存在多个最短或最快路径时选择最优解。

Input our current position and a destination, an online map can recommend several paths. Now your job is to recommend two paths to your user: one is the shortest, and the other is the fastest. It is guaranteed that a path exists for any request.

Input Specification:

Each input file contains one test case. For each case, the first line gives two positive integers N (2≤N≤500), and M, being the total number of streets intersections on a map, and the number of streets, respectively. Then M lines follow, each describes a street in the format:
V1 V2 one-way length time
where V1 and V2 are the indices (from 0 to N−1) of the two ends of the street; one-way is 1 if the street is one-way from V1 to V2, or 0 if not; length is the length of the street; and time is the time taken to pass the street.
Finally a pair of source and destination is given.

Output Specification:

For each case, first print the shortest path from the source to the destination with distance D in the format:
Distance = D: source -> v1 -> … -> destination
Then in the next line print the fastest path with total time T:
Time = T: source -> w1 -> … -> destination
In case the shortest path is not unique, output the fastest one among the shortest paths, which is guaranteed to be unique. In case the fastest path is not unique, output the one that passes through the fewest intersections, which is guaranteed to be unique.
In case the shortest and the fastest paths are identical, print them in one line in the format:
Distance = D; Time = T: source -> u1 -> … -> destination

两点之间的时间也可以看作某种长度,再用dijkstra算法,并且注意第一标尺相同时比较第二标尺即可。

问题就是写的有点多了

#include<iostream>
#include<vector>
using namespace std;
const int maxn = 510;
const int inf = 0x3fffffff;
int length[maxn][maxn], Time[maxn][maxn], n, m, suc, des;
int disL[maxn], disT[maxn], num[maxn], markL[maxn], markT[maxn], t[maxn];
int preL[maxn], preT[maxn];
void dijistra(int s) {
	disT[s] = 0;
	num[s] = 1;
	for (int i = 0; i < n; i++) {
		int pos = -1, min = inf;
		for (int j = 0; j < n; j++) {
			if (markT[j] == 0 && disT[j] < min) {
				pos = j;
				min = disT[j];
			}
		}
		if (pos == -1)return;
		markT[pos] = 1;
		for (int j = 0; j < n; j++) {
			if (markT[j] == 0) {
				if (disT[j] > disT[pos] + Time[pos][j]) {
					disT[j] = disT[pos] + Time[pos][j];
					preT[j] = pos;
					num[j] = num[pos] + 1;
				}
				else if (disT[j] == disT[pos] + Time[pos][j]) {
					if (num[pos] + 1 < num[j]) {
						preT[j] = pos;
						num[j] = num[pos] + 1;
					}
				}
			}
		}
	}
	disL[s] = 0;
	t[s] = 0;
	for (int i = 0; i < n; i++) {
		int pos = -1, min = inf;
		for (int j = 0; j < n; j++) {
			if (markL[j] == 0 && disL[j] < min) {
				pos = j;
				min = disL[j];
			}
		}
		if (pos == -1)return;
		markL[pos] = 1;
		for (int j = 0; j < n; j++) {
			if (markL[j] == 0) {
				if (disL[j] > disL[pos] + length[pos][j]) {
					disL[j] = disL[pos] + length[pos][j];
					preL[j] = pos;
					t[j]= t[j] = t[pos] + Time[pos][j];
				}
				else if (disL[j] == disL[pos] + length[pos][j]) {
					if (t[pos] + Time[pos][j] < t[j]) {
						preL[j] = pos;
						t[j] = t[pos] + Time[pos][j];
					}
				}
			}
		}
	}
}
void dfsL(int i) {
	if (i == preL[i])return;
	dfsL(preL[i]);
	cout << " -> " << i;
}
void dfsT(int i) {
	if (i == preT[i])return;
	dfsT(preT[i]);
	cout << " -> " << i;
}
int main() {
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		disT[i] = disL[i] = num[i] = t[i] = inf;
		preL[i] = preT[i] = i;
		markT[i] = markL[i] = 0;
		for (int j = 0; j < n; j++) {
			length[i][j] = Time[i][j] = inf;
		}
	}
	for (int i = 0; i < m; i++) {
		int x, y, dir, l, t;
		cin >> x >> y >> dir >> l >> t;
		if (dir == 0) {
			length[y][x] = l;
			Time[y][x] = t;
		}
		length[x][y] = l;
		Time[x][y] = t;
	}
	cin >> suc >> des;
	dijistra(suc);
	int temp = des;
	bool isSame = true;
	while (temp != suc) {
		if (preT[temp] != preL[temp]) {
			isSame = false;
			break;
		}
		temp = preL[temp];
	}
	if (isSame)cout << "Distance = " << disL[des] << "; ";
	else {
		cout << "Distance = " << disL[des] << ": " << suc;
		dfsL(des);
		cout << endl;
	}
	cout << "Time = " << disT[des] << ": " << suc;
	dfsT(des);
	cout << endl;
	return 0;
}
ArcGIS 中的 **Online Map** 功能是指通过 **ArcGIS Online** 提供的基于云的地图服务,用户可以访问、创建、共享和管理地图、图层、数据以及地理空间资源。该功能整合了全球范围内的底图、地图数据、应用程序、可配置模板和开发工具,支持用户构建和发布 Web 地图及地理信息应用[^1]。 ### 核心功能与特点 1. **丰富的底图与图层资源** ArcGIS Online 提供了多种底图选项,包括地形图、卫星影像、街道地图等,同时也支持用户通过在线服务(如高德地图、Wayback影像地图等)加载第三方图层[^2]。 2. **Web 地图创建与管理** 用户可以通过 ArcGIS Online 创建交互式 Web 地图,添加本地或在线数据图层,并进行样式配置、符号化设置和图层管理。地图可以保存在用户的组织中,并与团队共享或公开发布[^1]。 3. **集成故事地图(Story Maps)** 通过 ArcGIS StoryMaps,用户可以将地图与文本、图片、视频等内容结合,制作具有叙述性的可视化项目。该功能广泛应用于教育、宣传、灾害管理等领域。 4. **支持在线服务发布与调用** 用户可以发布地图服务、要素服务、影像服务等,并通过 REST API 或 Web 应用程序调用这些服务。开发者可以利用 ArcGIS API 构建定制化的 GIS 应用程序。 5. **协作与共享能力** ArcGIS Online 支持多用户协作,用户可以创建群组、共享内容,并设置权限控制。组织内的成员可以共同编辑地图、析数据和查看仪表板[^1]。 6. **跨平台与移动支持** 所有通过 Online Map 创建的地图和应用均可在桌面浏览器、移动设备和 ArcGIS 应用程序中访问,实现跨平台使用。 7. **扩展性与插件支持** 用户可以通过自定义模板、添加外部图层(如 TMS、WMS 等)来扩展地图内容。例如,在 ArcMap 中可以直接从 ArcGIS Online 添加图层,也可以手动配置第三方地图服务作为底图[^2][^3]。 ### 示例:添加在线底图(如高德地图)的配置方式 ```xml <TileLayer> <Name>高德地图</Name> <UrlTemplate>https://webst0{s}.is.autonavi.com/appmaptile?style=6&x={x}&y={y}&z={z}</UrlTemplate> <SubDomains>1,2,3,4</SubDomains> </TileLayer> ``` 通过上述配置,可以将高德地图作为底图加载到 ArcGIS Online 或 ArcMap 中,实现多源数据的融合展示[^3]。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值