首页 > 其他分享 >test

test

时间:2022-09-27 00:45:46浏览次数:45  
标签:int read edge test inline include dis

附上代码

/************************************************
*Author        :  demonlover
*Created Time  :  2022.05.21.20:42
*Problem       :  ABC252E
************************************************/
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
using namespace std;
typedef long long ll;
#define int ll
typedef long double ld;
typedef pair <int,int> pii;
template <typename T>
inline bool read(T &x) {
	int f = 1,c = getchar();x = 0;
	while (!isdigit(c)) {if (c == 45)f = -1;c = getchar();}
	while (isdigit(c))x = (x<<3)+(x<<1)+(c^48),c = getchar();
	return x *= f,true;
}
template <typename T,typename... Args>
inline bool read(T &x,Args &...args) {
	return read(x) && read(args...);
}

namespace run {
	const int maxn = 2e5+10,maxm = 2e5+10;
	struct Edge {int nxt,to,w,id;}edge[maxm<<1];
	int begn[maxn],e;
	inline void add(int x,int y,int z,int id) {
		edge[++e] = (Edge){begn[x],y,z,id};begn[x] = e;
		return;
	}
	int dis[maxn];
	int fro[maxn];
	bool vis[maxn];
	priority_queue< pii > q;
	inline void dijkstra(int s) {
		memset(dis,0x7f,sizeof(dis));
		dis[s] = 0,q.push(make_pair(0,s));
		while (!q.empty()) {
			int x = q.top().second;q.pop();
			if (vis[x])continue;
			vis[x] = true;
			for (int i = begn[x];i;i = edge[i].nxt) {
				int y = edge[i].to;
				if (dis[y] > dis[x]+edge[i].w) {
					dis[y] = dis[x]+edge[i].w;
					fro[y] = edge[i].id;
					if (!vis[y])q.push(make_pair(-dis[y],y));
				}
			}
		}
		return;
	}
	int n,m;
	inline bool main() {
		read(n,m);
		for (int i = 1,x,y,z;i <= m;++i)read(x,y,z),add(x,y,z,i),add(y,x,z,i);
		dijkstra(1);
		for (int i = 2;i <= n;++i)cout<<fro[i]<<" ";
		cerr<<1.0*clock()/CLOCKS_PER_SEC<<"\n";
		return 0;
	}
}

#undef int
#define demonlover
int main() {
#ifdef demonlover
	freopen("ABC252E.in","r",stdin);
	freopen("ABC252E.out","w",stdout);
#endif
	return run :: main();
}

标签:int,read,edge,test,inline,include,dis
From: https://www.cnblogs.com/Lonely923/p/16733099.html

相关文章

  • 微软出品自动化神器Playwright,不用写一行代码(Playwright+Java)系列(三) 之 手把手带你
    写在前面官方给的栗子是Junit,但是我还是用TestNG来进行脚本的编写,这里只分享思路,不管是哪个测试框架基本思路都是一样的,喜欢用官方的Junit的,建议查看官方文档。如何编写......
  • 封装unittest
    importunittestfromtools.http_rquestsimportHttpRequestsfromtools.get_dataimportGetCookiefromddtimportddt,datafromtools.do_excelimportDoExcelfromco......
  • The 2022 ICPC Asia Regionals Online Contest (II) B
    BNon-decreasingArray我们可以知道两个操作都是一样的那我们直接记dp[i][j]为前i个数选了j个数并且以ai为结尾的max状态转移直接枚举dp[k][j-1]+(a[i]-a[k])^2即可......
  • Test 2022.09.26
    今天是水题专场T1扩散感觉这种要么就是二分答案网络流,要么就是最小生成树,(随便口胡的),树德保留节目了属于是。分析简简单单一眼最小生成树(又是),边权就是两个点之间存在公......
  • ICPC2022 Online Contest 2 游记
    总结,8个题,前期罚时爆炸,后期坐牢。开局先找到签到题【E】。题意是给定\(a_1\)要求构造数组\(a_i\),满足\(\gcd(a_i,a_{i-1})==1\)且\(a_i>1\)。显然直接贪一波,......
  • 复制流报错:Latest checkpoint is at 2/7C3079A0 on timeline 1, but in the history o
    我的测试环境从PostgreSQL9.6.0异步复制流通过pg_upgrade方式升级到14.5,通过rsync将primary数据传输到standby端[postgres]]#rsync-avzpostgres@standby:/data/postgr......
  • AtCoder Beginner Contest 270
    AtCoder五十连练第一练AtCoderBeginnerContest270A-1-2-4Test考试有三道题,分别是\(1\)分、\(2\)分、\(4\)分。高桥、青木和Snuke参加了这次考试。高桥得......
  • AtCoder Beginner Contest 270
    A.1-2-4Test水题。B.Hammer分裂讨论。codeC.Simplepath一遍dfs就完了,怎么还有这种搜索题!codeD.Stones观察数据范围,\(O(NK)\)可过。\(dp_i\)表示\(i\)......
  • Leetcode weekly contest 312
    Leetcodeweeklyconetest3121.按身高排序解法:直接利用STL中的sort来自定义排序规则即可。Tag:自定义排序Code:classSolution{public:vector<string>so......
  • test
    test.pyimporttensorflowastfimportnumpyasnpdefadd_layer(inputs,in_size,out_size,activation_function=None):#inputs.shape=[None,1],in_size.shape=1......