[ABC271E] Subsequence Path 题解
1.AT_abc333_e [ABC333E] Takahashi Quest 题解2.[ABC265F] Manhattan Cafe 题解
3.[ABC271E] Subsequence Path 题解
4.[ABC273D] LRUD Instructions 题解5.P8085 [COCI2011-2012#4] KRIPTOGRAM 题解6.[ABC238F] Two Exams 题解7.[ABC217F] Make Pair 题解8.[ABC219F] Cleaning Robot 题解9.[ABC219E] Moat 题解10.[ABC221D] Online games 题解11.[ABC221E] LEQ 题解12.[ABC223E] Placing Rectangles 题解13.[ABC211D] Number of Shortest paths 题解14.[ABC211F] Rectilinear Polygons 题解15.[ABC223F] Parenthesis Checking 题解16.CF154C Double Profiles 题解17.[ABC208D] Shortest Path Queries 2 题解18.[ABC212E] Safety Journey 题解19.[ABC229E] Graph Destruction 题解20.[ABC240E] Ranges on Tree 题解21.[ABC261E] Many Operations 题解22.P10842 【MX-J2-T3】Piggy and Trees 题解[ABC271E] Subsequence Path 题解
思路解析
很好的一道题,很有迷惑性,表面上是一道图论实际上是 dp,定义
code
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 2e5 + 10;
ll n, m, k;
ll a[N], b[N], c[N];
ll e;
ll f[N];
int main() {
cin >> n >> m >> k;
for(int i = 1; i <= m; i++) {
cin >> a[i] >> b[i] >> c[i];
}
memset(f, 0x3f, sizeof(f));
f[1] = 0;
for(int i = 1; i <= k; i++) {
cin >> e;
f[b[e]] = min(f[b[e]], f[a[e]] + c[e]);
}
if(f[n] < 1e18) {
cout << f[n];
}
else {
cout << -1;
}
return 0;
}
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 提示词工程——AI应用必不可少的技术
· .NET周刊【3月第1期 2025-03-02】