传送门

Luogu

解题思路

分层图最短路,层与层之间的边的边权减半,然后就是板子了。

细节注意事项

  • 咕咕咕。

参考代码

#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#define rg register
using namespace std;
template < class T > inline void read(T& s) {
s = 0; int f = 0; char c = getchar();
while (!isdigit(c)) f |= c == '-', c = getchar();
while (isdigit(c)) s = s * 10 + c - 48, c = getchar();
s = f ? -s : s;
} const int _ = 52 * 52;
const int __ = 1002 + 52 * 2002; int tot, head[_], nxt[__ << 1], ver[__ << 1], w[__ << 1];
inline void Add_edge(int u, int v, int d)
{ nxt[++tot] = head[u], head[u] = tot, ver[tot] = v, w[tot] = d; } int n, m, k, vis[_], dis[_]; inline int id(int u, int x) { return u + x * n; } inline void Dijkstra() {
static priority_queue < pair < int, int > > Q;
memset(dis + 1, 0x3f, sizeof (int) * (n * (k + 1)));
dis[1] = 0, Q.push(make_pair(0, 1));
while (!Q.empty()) {
int u = Q.top().second; Q.pop();
if (vis[u]) continue; vis[u] = 1;
for (rg int i = head[u]; i; i = nxt[i]) {
int v = ver[i];
if (dis[v] > dis[u] + w[i])
dis[v] = dis[u] + w[i], Q.push(make_pair(-dis[v], v));
}
}
} int main() {
#ifndef ONLINE_JUDGE
freopen("cpp.in", "r", stdin);
freopen("cpp.out", "w", stdout);
#endif
read(n), read(m), read(k);
for (rg int u, v, d; m--; ) {
read(u), read(v), read(d);
Add_edge(u, v, d), Add_edge(v, u, d);
for (rg int i = 1; i <= k; ++i) {
Add_edge(id(u, i), id(v, i), d);
Add_edge(id(v, i), id(u, i), d);
Add_edge(id(u, i - 1), id(v, i), d >> 1);
Add_edge(id(v, i - 1), id(u, i), d >> 1);
}
}
Dijkstra();
int ans = 2147483647;
for (rg int i = 0; i <= k; ++i)
ans = min(ans, dis[id(n, i)]);
printf("%d\n", ans);
return 0;
}

完结撒花 \(qwq\)

「BJWC2012」冻结的更多相关文章

  1. 「译」JUnit 5 系列:条件测试

    原文地址:http://blog.codefx.org/libraries/junit-5-conditions/ 原文日期:08, May, 2016 译文首发:Linesh 的博客:「译」JUni ...

  2. 「译」JUnit 5 系列:扩展模型(Extension Model)

    原文地址:http://blog.codefx.org/design/architecture/junit-5-extension-model/ 原文日期:11, Apr, 2016 译文首发:Lin ...

  3. JavaScript OOP 之「创建对象」

    工厂模式 工厂模式是软件工程领域一种广为人知的设计模式,这种模式抽象了创建具体对象的过程.工厂模式虽然解决了创建多个相似对象的问题,但却没有解决对象识别的问题. function createPers ...

  4. 「C++」理解智能指针

    维基百科上面对于「智能指针」是这样描述的: 智能指针(英语:Smart pointer)是一种抽象的数据类型.在程序设计中,它通常是经由类型模板(class template)来实做,借由模板(tem ...

  5. 「JavaScript」四种跨域方式详解

    超详细并且带 Demo 的 JavaScript 跨域指南来了! 本文基于你了解 JavaScript 的同源策略,并且了解使用跨域跨域的理由. 1. JSONP 首先要介绍的跨域方法必然是 JSON ...

  6. 「2014-5-31」Z-Stack - Modification of Zigbee Device Object for better network access management

    写一份赏心悦目的工程文档,是很困难的事情.若想写得完善,不仅得用对工具(use the right tools),注重文笔,还得投入大把时间,真心是一件难度颇高的事情.但,若是真写好了,也是善莫大焉: ...

  7. 「2014-3-18」multi-pattern string match using aho-corasick

    我是擅(倾)长(向)把一篇文章写成杂文的.毕竟,写博客记录生活点滴,比不得发 paper,要求字斟句酌八股结构到位:风格偏杂文一点,也是没人拒稿的.这么说来,arxiv 就好比是 paper 世界的博 ...

  8. 「2014-3-17」C pointer again …

    记录一个比较基础的东东-- C 语言的指针,一直让人又爱又恨,爱它的人觉得它既灵活又强大,恨它的人觉得它太过于灵活太过于强大以至于容易将人绕晕.最早接触 C 语言,还是在刚进入大学的时候,算起来有好些 ...

  9. 「2014-3-13」Javascript Engine, Java VM, Python interpreter, PyPy – a glance

    提要: url anchor (ajax) => javascript engine (1~4 articles) => java VM vs. python interpreter =& ...

随机推荐

  1. window下jenkins+allure+邮箱发送

    一.安装allure 1)下载 allure.zip 下载地址:allure-github: https://github.com/allure-framework/allure2 2)解压到本地目录 ...

  2. Nexus-VDC(Virtual Device Context)

    VDC实际上是将一台物理的Nexus7K设备虚拟为多个逻辑的VDC设备,该术语叫做VDC(Virtual Device Context),该虚拟技术实际上是在一个物理设备架构和内核上运行多个VDC,已 ...

  3. 2016-2017学年第三次测试赛 问题 F: 签到题

    问题 F: 签到题 时间限制: 1 Sec  内存限制: 128 MB提交: 80  解决: 28 提交统计讨论版 题目描述 在计算机网络考试中, 黑帅男神看到一个将IP网络分类的题, 精通C++的他 ...

  4. 【原】Django问题总结

    一:python manage.py makemigrations No changes detected 在修改了models.py后,有些用户会喜欢用python manage.py makemi ...

  5. ➡️➡️➡️IELTS speaking by simon

    目录 p1 课程概述 p2 speaking part1, intro, warm up introduction questions then 4 questions about one topic ...

  6. 【PAT甲级】1062 Talent and Virtue (25 分)

    题意: 输入三个正整数N,L,H(N<=1E5,L>=60,H<100,H>L),分别代表人数,及格线和高水平线.接着输入N行数据,每行包括一个人的ID,道德数值和才能数值.一 ...

  7. office365激活码序列号密钥:

    亲测可用: NGCM9-FWB6X-9WKYC-GRWVD-63B3P  

  8. linux环境安装包方式

    概述 安装有很多种,有时我们会混淆视听不知在什么场景或什么情况下用什么命令,下面讲解下几种安装命令的使用.希望对大家有帮助~ 详解 pip install kuming或 python -m pip ...

  9. 【摘录自MDN】对事件冒泡和捕捉的解释

    当一个事件触发了一个有父元素的元素(例如我们的<video>时),现代浏览器运行两个不同的阶段 - 捕获阶段和冒泡阶段. 在捕获阶段: 浏览器检查元素的最外层祖先(<html> ...

  10. Windows 安装python虚拟环境

    windows 安装pytho虚拟环境 方法一:virtualenv (1)使用pip安装virtualenv工具 pip install virtualenv (2)使用virtualenv创建虚拟 ...