正题 题目链接:https://www.luogu.com.cn/problem/AT4505 题目大意 给出\(n\)个点和\(n-1\)个点集\(U_i\),每个点集中选择两个点连边使得该图是一棵树.求方案. \(n\in[1,10^5],\sum_{i=1}^{n-1} |U_i|\in[1,2*10^5]\) 解题思路 冬令营上讲的题目,现在来写.(而且好像我记得课上讲的做法是\(bitset\)的,还是时间久了我记岔了?) 第一眼看上去直觉像是\(hall\)定理但还是不会. hall…
目录 @description@ @solution@ @accepted code@ @details@ @description@ 给定 N - 1 个 {1, 2, ..., N} 的子集,第 i 个为 Ei. 请构造 N - 1 条边 (u1, v1), (u2, v2), ... 使得 ui ∈ Ei 且 vi ∈ Ei,满足这 N - 1 条边构成一棵树. 原题传送门. @solution@ 好神的题. 构造一个二分图,第 i 条边对应的点连向 Ei 中所有的点. 有解的一个充分条件…
比赛时候还是太慢了……要是能做快点就能上分了 Monocarp has drawn a tree (an undirected connected acyclic graph) and then has given each vertex an index. All indices are distinct numbers from 11 to nn. For every edge ee of this tree, Monocarp has written two numbers: the ma…
Binary Tree 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5573 Description The Old Frog King lives on the root of an infinite tree. According to the law, each node should connect to exactly two nodes on the next level, forming a full binary tree. S…
C - Upgrading Tree 我发现我构造题好弱啊啊啊. 很明显能想到先找到重心, 然后我们的目标就是把所有点接到重心的儿子上,让重心的儿子子树变成菊花图, 这个先把重心到儿子的边连到 i , 然后把 i 到 其 fa 的边连到重心的儿子上, 一直循环就好啦. #include<bits/stdc++.h> #define LL long long #define fi first #define se second #define mk make_pair #define PLL p…
C. Devu and Partitioning of the Array time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Devu being a small kid, likes to play a lot, but he only likes to play with arrays. While playing he ca…
link:http://acm.hdu.edu.cn/showproblem.php?pid=4671 其实是不难的那种构造题,先排第一列,第二列从后往前选. #include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <cctype> #include <algorithm> #…
D. Optimal Number Permutation 题目连接: http://www.codeforces.com/contest/622/problem/D Description You have array a that contains all integers from 1 to n twice. You can arbitrary permute any numbers in a. Let number i be in positions xi, yi (xi < yi) i…
这是一道蛮基础的构造题. - k         +(k - 1)      -(k - 2) 1 + k ,    1 ,         k ,             2,    ................... \  /        \  /           \  / k          k-1          k-2 如图所示,先构造第一个数,就是1 + k, 然后接下来每个数字和上个数相差k , k -1 , k -2 这样下来,最后一个数字就是一个中间的数字,过程就…
3097: Hash Killer I Time Limit: 5 Sec  Memory Limit: 128 MBSec  Special JudgeSubmit: 963  Solved: 364[Submit][Status][Discuss] Description 这天天气不错,hzhwcmhf神犇给VFleaKing出了一道题: 给你一个长度为N的字符串S,求有多少个不同的长度为L的子串. 子串的定义是S[l].S[l + 1].... S[r]这样连续的一段. 两个字符串被认为是…