trie合并的裸题...因为最多只有n个点,所以最多合并n次,复杂度$O(N*26)$. #include<iostream> #include<cstring> #include<cstdlib> #include<cstdio> using namespace std; , inf=1e9; ]; ], size;}tree[maxn]; int n, x, y, ans, cnt, tot; int last[maxn], c[maxn]; char…
D. Acyclic Organic Compounds You are given a tree T with n vertices (numbered 1 through n) and a letter in each vertex. The tree is rooted at vertex 1. Let's look at the subtree Tv of some vertex v. It is possible to read a string along each simple…
A.The Two Routes(BFS) 给出n个城镇,有m条铁路,铁路的补图是公路,汽车和火车同时从1出发,通过每条路的时间为1,不能同时到达除了1和n的其它点,问他们到达n点最少要用多长时间. 因为是补图,那么一定有一条路是可以直接从1到达n的.那么我们把剩下的用bfs求一下即可. # include <cstdio> # include <cstring> # include <cstdlib> # include <iostream> # incl…