模板

各种模板,赛前打打。

basic

#include <bits/stdc++.h>
#define mk make_pair
#define E(i,l,r) for(int i=l;i<=r;++i)
#define rd() read<ll>()
using ll = long long;
using namespace std;
using P = pair<int,int>;
const int N = 5e5 + 10;
int n,k;
template <typename T> inline T read(){
	T x = 0; char c = getchar(); bool f = 0;
	while (!isdigit(c)) if (c=='-') f = 1, c = getchar();
	while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
	return f ? -x : x;
}
template <typename T> void write(T x){
	if (x < 0) { putchar('-'), x=-x; }
	if (x > 9) write(x / 10);
	putchar(x % 10 ^ 48);
}
vector <P> g[N];
int main(){
	n = rd(), k = rd();
	for(int x,y,z,i=1;i < n; ++i) x = rd(), y = rd(), z = rd(), g[x].emplace_back(mk(y,z)), g[y].emplace_back(mk(x,z));
	
}
posted @ 2025-10-21 16:41  ChihiroFujisaki  阅读(4)  评论(0)    收藏  举报