惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

A
About on SuperTechFans
C
Cybersecurity and Infrastructure Security Agency CISA
N
News and Events Feed by Topic
C
Cisco Blogs
Cisco Talos Blog
Cisco Talos Blog
A
Arctic Wolf
Scott Helme
Scott Helme
P
Palo Alto Networks Blog
S
Schneier on Security
D
Darknet – Hacking Tools, Hacker News & Cyber Security
T
Tor Project blog
量子位
G
Google Developers Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
B
Blog RSS Feed
NISL@THU
NISL@THU
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
AWS News Blog
AWS News Blog
爱范儿
爱范儿
Last Week in AI
Last Week in AI
Y
Y Combinator Blog
L
LINUX DO - 最新话题
Security Archives - TechRepublic
Security Archives - TechRepublic
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
S
Secure Thoughts
Cloudbric
Cloudbric
aimingoo的专栏
aimingoo的专栏
L
Lohrmann on Cybersecurity
TaoSecurity Blog
TaoSecurity Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Hacker News: Ask HN
Hacker News: Ask HN
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
The GitHub Blog
The GitHub Blog
有赞技术团队
有赞技术团队
S
Security @ Cisco Blogs
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Cyber Attacks, Cyber Crime and Cyber Security
G
GRAHAM CLULEY
P
Proofpoint News Feed
V
V2EX
Martin Fowler
Martin Fowler
C
CERT Recently Published Vulnerability Notes
Attack and Defense Labs
Attack and Defense Labs
C
CXSECURITY Database RSS Feed - CXSecurity.com
The Cloudflare Blog
SecWiki News
SecWiki News
罗磊的独立博客
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
小众软件
小众软件
The Last Watchdog
The Last Watchdog

Makerlife 的小站

2025-2026 赛季 游记 && 退役记 NOIP 2024 游记 CSP2024 游记 板子库 动态规划 刷题记录 杂题乱记 数学期望 学习笔记 数论 学习笔记 CF1000F One Occurrence 题解 P6878 [JOI 2020 Final] JJOOII 2 题解 CSP2023 游寄 主定理 CF1695C Zero Path 题解 字符串算法全家桶 学习笔记 AT_ABC306D 题解 2023.06.03 模拟赛 Azure for Students 使用指北 AT_ABC286C 题解 洛谷 AT1898 题解 洛谷 CF1036A 题解 洛谷 CF1040A 题解 洛谷 SP3591 题解 洛谷 AT278 题解 洛谷 CF141B 题解 洛谷 AT2561 题解 洛谷 AT3525 题解 洛谷 CF899B 题解 洛谷 AT4787 题解 洛谷 AT4810 题解 洛谷 SP5450 题解
集训记录
Makerlife · 2024-11-20 · via Makerlife 的小站

P4823

贪心按 a+ba+b 从小到大排序,小的先走,正确性反证得到:

  • 设有两个人 iijj,且 ai+bi>aj+bja_i+b_i>a_j+b_j,且两人出去的顺序为 i→ji\to j,也就是高的在上面。
  • 那么,现在交换两个人,按照反证的假设如果原来 iijj 都能出去,那么现在只有 ii 能出去,且根据题意,其一定能出去;
  • jj 现在都出不去,那么由于 jjii 高,那么在不交换前,两人基准位置相同,更矮的 ii 一定出不去。矛盾,得证。

转化为选 ii 踮脚或逃的背包。fi,jf_{i,j} 表示前 ii 个人总高度为 jj 最多逃多少人。注意到 jj 可能很大,考虑把结果和状态换一下,fi,jf_{i,j} 表示前 ii 个人,逃 jj 个能搭起来的最大高度。

f0≔∑i=1naifj=fj−1−ai (fj−1+bi≥h)f_0\coloneqq \sum_{i=1}^{n}a_i\\ f_{j}=f_{j-1}-a_i\ (f_{j-1}+b_i\geq h)

模拟赛 T2

给定一棵树,求一个删边的构造,使得任意删除新的图中的一条边图仍然联通。

[证明]

设叶子 mm 个,则答案数 ⌈m2⌉\lceil \dfrac{m}{2}\rceil

按 dfn 对叶子节点编号,则每次删的边构造可以为 i→i+⌊m2⌋i\to i+\lfloor\dfrac{m}{2}\rfloor

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
bitset<N> leaf;
vector<int> dfn;
void dfs(int u, int fa) {
if (leaf[u]) dfn.push_back(u);
for (auto v : e[u]) {
if (v == fa) continue;
dfs(v, u);
}
}
int main() {
n = read();
for (int i = 1; i < n; i++) {
int u = read(), v = read();
e[u].push_back(v);
e[v].push_back(u);
}
int m = 0;
for (int i = 1; i <= n; i++) {
if (e[i].size() == 1) {
leaf[i] = 1;
m++;
}
}
dfs(1, 0);
cout << ((m + 1) >> 1) << '\n';
for (int i = 0; i <= (m >> 1) - 1; i++) {
cout << dfn[i] << " " << dfn[i + (m >> 1)] << '\n';
}
if (m & 1) {
cout << dfn.front() << " " << dfn.back() << '\n';
}
return 0;
}

CF1251D

二分枚举中位数,考虑贪心地 check。将要求转化为一段段区间,对于一个区间 ii,有三种情况:中位数大于/小于区间或在区间内。

  • 对于前两种情况,一定不会产生中位数,为了省钱选下界;
  • 对于第三种情况,因为此时剩余数量已经确定,故对于一半的数选中位数,另外全选下界。选下界的这一半为了省钱,在下界相对小的区间选。

check 过程中判一下如果前两种情况的数量大于中位数一定不合法即可。