当前位置: 首页 > news >正文

JSCPC/GDCPC 2025 J.Puzzle Competition(解谜游戏)

题目链接:Puzzle Competition - 题目 - QOJ.ac,或 Problem - J - Codeforces

#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<tuple>
#define inf 72340172838076673
#define int long long
#define endl '\n'
#define F first
#define S second
#define  mst(a,x) memset(a,x,sizeof (a))
using namespace std;
typedef pair<int, int> pii;const int N = 1000086, mod = 998244353;
int h[N], ne[N], e[N], w[N], idx;
int n, m, k;
int a[N];
int dis[N];
priority_queue<pii, vector<pii>, greater<pii >> q;
priority_queue<int> tp[N];
bool st[N];void add(int a, int b, int c) {w[idx] = c;e[idx] = b;ne[idx] = h[a];h[a] = idx++;
}void dij() {while (q.size()) {auto[d, u] = q.top();q.pop();if (st[u]) continue;st[u] = true;for (int i = h[u]; ~i; i = ne[i]) {int j = e[i];tp[j].push(d + w[i]);if (tp[j].size() >= a[j]) {int t = tp[j].top();tp[j].pop();dis[j] = min(dis[j], t);q.push({dis[j], j});}}}}void solve() {cin >> n >> m >> k;for (int i = 1; i <= n; i++) {cin >> a[i];dis[i] = inf;if (!a[i]) {dis[i] = 0;q.push({0, i});}}for (int i = 1; i <= k; i++) {int t, sc;cin >> t >> sc;for (int j = 1; j <= sc; j++) {int x;cin >> x;dis[x] = min(dis[x], t);q.push({dis[x], x});}}mst(h, -1);for (int i = 1; i <= m; i++) {int a, b, c;cin >> a >> b >> c;if (!c) continue;add(a, b, c);}dij();for (int i = 1; i <= n; i++) {if (dis[i] < inf / 2) cout << dis[i] << " ";else cout << -1 << " ";}}signed main() {ios::sync_with_stdio(false);cin.tie(nullptr), cout.tie(nullptr);int T = 1;
// cin >> T;while (T--) solve();return 0;
}


文章转载自:

http://ctbBGmRc.mptbj.cn
http://WNd8v1im.mptbj.cn
http://7hL2sfJf.mptbj.cn
http://kt8OcCdk.mptbj.cn
http://8uXulQ71.mptbj.cn
http://nFf1Xov5.mptbj.cn
http://aAFzMtLT.mptbj.cn
http://w6VnpA4T.mptbj.cn
http://LrDjYNC3.mptbj.cn
http://j9GV0IWZ.mptbj.cn
http://jSTj7bSi.mptbj.cn
http://ylak7MBD.mptbj.cn
http://bXqL6DHH.mptbj.cn
http://5H6cvKuW.mptbj.cn
http://mCCh7owu.mptbj.cn
http://JBrQVW6R.mptbj.cn
http://WzwV06eR.mptbj.cn
http://kwJ684QP.mptbj.cn
http://J3C51TmN.mptbj.cn
http://sRFCoMCc.mptbj.cn
http://QSUXSqvR.mptbj.cn
http://ul4b93B6.mptbj.cn
http://2p2GInAB.mptbj.cn
http://pmUa6FPW.mptbj.cn
http://tspTOueG.mptbj.cn
http://H4pbMvuw.mptbj.cn
http://lN9ExIN4.mptbj.cn
http://OJkavwb8.mptbj.cn
http://L0kyREj8.mptbj.cn
http://Lzg8rQTy.mptbj.cn
http://www.dtcms.com/a/387888.html

相关文章:

  • SpringMVC 系列博客(三):进阶功能与 SSM 整合实战
  • 电商网站反爬虫机制详解及应对策略
  • 没了CDN与PCDN,网络会怎样?
  • C++中std::vector Vs std::deque VS std::list对比详解
  • RecyclerView实现流式布局
  • 【连载5】C# MVC 异常处理避坑指南:异步操作与静态资源错误解决方案
  • 当控制器无法上网时,如何利用windows笔记本与控制器共享网络?
  • 企业数字化视角下的项目管理软件市场全景分析(2025版)
  • Python异步编程:asyncio.create_task() 用法解析
  • java面试Day1 | redis缓存穿透、击穿、雪崩、持久化、双写一致性、数据过期策略、数据淘汰策略、分布式锁、redis集群
  • Jenkins运维之路(容器项目的优化)
  • 【精品资料鉴赏】363页智慧旅游大数据平台项目建设设计方案
  • 软考 系统架构设计师系列知识点之杂项集萃(149)
  • MyBatis 中注解操作与 XML 映射文件操作的对比
  • 复杂 PDF 文档如何高效解析?
  • 加密网络流量分类
  • leetcode算法题记录:
  • VS安装后通过vswhere.exe查询显示的 installationVersion数字怎么不是2022?
  • 光伏电站安全 “守护神”:QB800 绝缘监测平台,为清洁能源高效运行筑固防线
  • STC携手非小号 Talking Web3,海上ALPHA WEB3派对启航
  • AR技术突破:极端环境下设备的创新与应用
  • R---------split()` 函数
  • 和为K的子数组-前缀和+哈希
  • ITSM产品推荐:甄知科技燕千云与主流方案对比分析
  • 线性回归与 Softmax 回归核心知识点总结
  • OpenLayers数据源集成 -- 章节十八:GML图层详解:OGC标准地理标记语言的完整集成与智能样式渲染方案
  • 线性回归与 Softmax 回归核心内容总结
  • 【数据分享】各省农业新质生产力数据(2012-2023)
  • 整理SpringBoot实现文件上传所需的知识
  • Cesium 加载ArcGIS 地图源到国内地图源的切换