当前位置:网站首页>Post disaster reconstruction -- Floyd thought
Post disaster reconstruction -- Floyd thought
2022-07-02 10:19:00 【Wawa source】
In the future, you must see the conditions clearly
The time array of this question is not reduced , The query is not reduced , I can't see , Mapping half a day ...

Topic link
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
typedef pair<int, int> PII;
const int N = 210,INF=0x3f3f3f3f;
int w[N];
int d[N][N];
int n,m;
signed main()
{
cin>>n>>m;
memset(d,0x3f,sizeof d);
for(int i=0;i<n;i++)cin>>w[i],d[i][i]=0;
for(int i=0;i<m;i++)
{
int a,b,c;
cin>>a>>b>>c;
d[a][b]=d[b][a]=c;
}
int q;
cin>>q;
int pos=0;
while(q--)
{
int x,y,t;
cin>>x>>y>>t;
for(;w[pos]<=t&&pos<n;pos++)
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
d[i][j]=d[j][i]=min(d[i][j],d[i][pos]+d[pos][j]);
if(w[x]>t||w[y]>t)cout<<-1<<'\n';
else
{
if(d[x][y]>INF/2)cout<<-1<<'\n';
else cout<<d[x][y]<<'\n';
}
}
}
边栏推荐
- This monitoring system makes workers tremble: turnover intention and fishing can be monitored. After the dispute, the product page has 404
- Remember the use of add method once
- Blender多镜头(多机位)切换
- 【MySQL】连接MySQL时出现异常:Connection must be valid and open
- allure--常用配置项
- 【避坑指南】使用UGUI遇到的坑:Text组件无法首行缩进两格
- The latest progress and development trend of 2022 intelligent voice technology
- Bookmark collection management software suspension reading and data migration between knowledge base and browser bookmarks
- How to handle error logic gracefully
- 2837xd代码生成模块学习(2)——ADC、ePWM模块、Timer0
猜你喜欢

MySQL index

Blender volume fog

SAP Spartacus express checkout design

UE4夜间打光笔记

Matlab generates DSP program -- official routine learning (6)

Illusion -- Animation blueprint, state machine production, character walking, running and jumping action

Ue5 - ai Pursuit (Blueprint, Behavior tree)

Junit4运行mvn test 测试套件升级方案

【虚幻4】UMG组件的简介与使用(更新中...)

2837xd code generation - stateflow (2)
随机推荐
Postman--使用
SAP Spartacus express checkout design
Edge computing accelerates live video scenes: clearer, smoother, and more real-time
[200 Shengxin literatures] 95 multiomics exploration TNBC
Matlab generates DSP program -- official routine learning (6)
Introduction to go language
【避坑指南】Unity3D项目接入腾讯Bugly工具时遇到的坑
Summary of demand R & D process nodes and key outputs
This article takes you to learn in detail what is fiber to home FTTH
【Lua】常见知识点汇总(包含常见面试考点)
Basic notes of illusory AI blueprint (10000 words)
Remember a simple Oracle offline data migration to tidb process
2837xd code generation - Supplement (2)
Project practice, redis cluster technology learning (16)
【Unity3D】制作进度条——让Image同时具有Filled和Sliced的功能
Commutateur Multi - lentilles Blender
Blender多鏡頭(多機比特)切換
Applet development summary
Project practice, redis cluster technology learning (6)
ERROR 1118 (42000): Row size too large (&gt; 8126)