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

推荐订阅源

Engineering at Meta
Engineering at Meta
T
Threatpost
P
Palo Alto Networks Blog
NISL@THU
NISL@THU
O
OpenAI News
Project Zero
Project Zero
G
GRAHAM CLULEY
P
Privacy International News Feed
A
Arctic Wolf
Microsoft Azure Blog
Microsoft Azure Blog
H
Help Net Security
M
MIT News - Artificial intelligence
T
Threat Research - Cisco Blogs
S
Security @ Cisco Blogs
Google DeepMind News
Google DeepMind News
B
Blog RSS Feed
D
Docker
aimingoo的专栏
aimingoo的专栏
博客园 - 【当耐特】
N
Netflix TechBlog - Medium
云风的 BLOG
云风的 BLOG
雷峰网
雷峰网
W
WeLiveSecurity
P
Proofpoint News Feed
腾讯CDC
Cloudbric
Cloudbric
S
Secure Thoughts
C
Check Point Blog
博客园 - Franky
T
The Exploit Database - CXSecurity.com
T
Troy Hunt's Blog
GbyAI
GbyAI
Security Archives - TechRepublic
Security Archives - TechRepublic
Application and Cybersecurity Blog
Application and Cybersecurity Blog
月光博客
月光博客
C
Cyber Attacks, Cyber Crime and Cyber Security
I
Intezer
TaoSecurity Blog
TaoSecurity Blog
L
Lohrmann on Cybersecurity
V
Visual Studio Blog
F
Fortinet All Blogs
博客园 - 叶小钗
C
CXSECURITY Database RSS Feed - CXSecurity.com
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Recorded Future
Recorded Future
C
Cisco Blogs
博客园 - 司徒正美
Stack Overflow Blog
Stack Overflow Blog
Y
Y Combinator Blog
Apple Machine Learning Research
Apple Machine Learning Research

某岛

AtCoder Beginner Contest 409 Luogu P5325. 【模板】Min_25 筛 UOJ #188. 【UR #13】Sanrd AtCoder Beginner Contest 371 AtCoder Beginner Contest 369 RPGMaker 2k3 百科 OneShot 的考古 2024“开创拓芯”游戏创享节的相关记录 CJ 回来后的戒断反应 Luogu P10221. [省选联考 2024] 重塑时光 Luogu P5308 [COCI2018-2019#4] Akvizna wqs 二分 歌唱王国 Lean 相关 BZOJ 3153. Sone1 The 2023 ICPC World Finals Luxor 新巴别塔 Sora 的想象与思考 Facebook Hacker Cup 2023 Round 1 AtCoder Beginner Contest 322 LLaMA 2 相关 HuggingFace AI Game Jam ACL 2023 Trans 相关… Luogu P2053. [SCOI2007] 修车 Luogu P1973. [NOI2011] NOI 嘉年华 Luogu P1933. [NOI2010] 旅行路线 Luogu P1954. [NOI2010] 航空管制 Luogu P2048. [NOI2010] 超级钢琴 Luogu P2046. [NOI2010] 海拔 Luogu P3227. [HNOI2013] 切糕 Luogu P8500. [NOI2022] 冒泡排序 Luogu P3629. [APIO2010] 巡逻 USACO 2018 February Contest, Gold Problem 2. Directory Traversal Luogu P3647. [APIO2014] 连珠线 IZhO 2017. Problem F. Hard route SPOJ TWOPATHS. Two Paths 换根 dp 洪恩电脑 —— 开天辟地 Facebook Hacker Cup 2022 Round 2 Codeforces Round #875 Luogu P5828 边双连通图计数 EC Final 拉格朗日反演定理 Luogu P5827. 点双连通图计数 无标号连通图 AtCoder Beginner Contest 284 Luogu P4708. 画画 Luogu P6295. 有标号 DAG 计数 BZOJ #2863. 愤怒的元首 HDU 3303. Harmony Forever 聊聊《明日方舟 Side Story 孤星》与《崩坏:星穹铁道》 SGU 208. Toral Tickets 后日谈,SHLUG 月度分享(上) 钢琴练习 EasyRPG x ChatGPT ControlNet 相关 The 1st Universal Cup, Stage 4, Ukraine EasyRPG —— Sliding Puzzle The 1st Universal Cup, Stage 3, Poland DP 优化练习 NOI 2009 TypeDB Forces 2023 Nas 买来做什么… Global Game Jam 2023 参赛纪录 The 1st Universal Cup, Stage 2, Hongkong The 1st Universal Cup, Stage 0, Nanjing Codeforces Round #850 舟游同人游戏 RM2k3 机能增强 —— EasyRPG Player 魔改版 《海之歌》设定与剧本 dfs 序求 lca Codeforces Round #844 P3768 简单的数学题 AtCoder Beginner Contest 281 ChatGPT 相关 AtCoder Grand Contest 059 AtCoder Beginner Contest 280 Codeforces Global Round 24 事实核查,以乌鲁木齐火灾为例 SPOJ MUSKET. Musketeers Pinely Round 1 Note about FTX Permutation ICPC World Final 2021 CodeTON Round 3 Codeforces Round #831 Educational Codeforces Round 138 NovelAI 法术指南 卡农 Educational Codeforces Round 135 Codeforces Round #819 瓦喵之夏 NOI 2022 Luogu P3765 总统选举 Luogu P3369 【模板】普通平衡树 网络国家 旋转卡壳 OFAC Sanctions && Tornado Cash BZOJ 1185. [HNOI2007]最小矩形覆盖
AtCoder Regular Contest 146
2022-08-25 · via 某岛

传送门

Problem A. Three Cards

取任意张也可做。排序两次,第一次用数字排序,第二次用字符串排序(但是要修改一下字典序的定义,不存在的字符取无穷大)。

Problem B. Plus and AND

题解里说二分,但是应该没有人会去写二分吧(复杂度一样)。。。
当然是去写按位贪心。。。每次确定第 i 位是否可以为 1,那么对于每个数需要求出与当前目标的距离。。
难点在于这个距离函数,需要各种讨论。

当然大牛们都是用位运算一行就把距离函数写出来的囧。。

Problem C. Even XOR

Problem E. Simple Speed

计数,问有多少种满足以下条件的整数序列:
1. 每个数字出现的次数恰好为 Ai。
2. 相邻位置的差的绝对值恰好为 1。

个人觉得这个 dp 非常的优雅!

首先不考虑条件 2,那么就是 多项式系数
考虑条件 2,我们似乎可以暴力 dp…
dp[i][j] 表示前 i 位,末尾为 j 的方案数,
但这个显然不可行。。因为我们没法记录每个数字当前还剩多少。。

所以核心是我们要避免去讨论当前状态里每个数字还剩多少。。。有办法吗?

答案是有的!逐层推进 就行,也就是用数字的大小划分阶段。。。

那么一开始显然只有。。
1 1 1
下一层,我们要把 2 插入 1 之间的空隙里。。。不妨考察两个边界情况。。。
最少需要 2 个 2。。。变成。。
1 2 1 2 1
最多似乎可以有 4 个 2。。。变成。。
2 1 2 1 2 1 2
其实不止。。因为我们还可以往两边任意的继续加 2。
只不过中间的这个 {2 1 2 1 2 1 2} 现在是一个整体,而且它现在等价于上一轮的一个 {1}。。。这样我们似乎找到了可以描述的状态。。序列的序列。。
比如如果我们有 6 个 2,那么这一轮我们可以是。。
{2} {2 1 2 1 2 1 2} {2}
{2 1 2 1 2 1 2} {2} {2}
{2} {2} {2 1 2 1 2 1 2} …
这三种情况,都和第一轮的 {1} {1} {1} 是等价的。。。

所以我们每一层的任务,就是连接这些子序列之间的空隙,并生成一些新的空隙。
或者更简单的理解。。。下一轮最后等价于一些 {3} {3} {3} 。。。然后我们用上一层的序列,去连接这一层的序列。。。简单组合数即可。。

难点是需要讨论两侧的状态,因为它们可能不可参与拼接。。

所以状态就是 dp[i][j][k]。。当前阶段为 i,两侧可拼接 j 次,中间还有 k 个位置可拼接。。
。。。
分析状态转移,我们会发现这个状态空间非常稀疏,直接开个 map 跑 dp 即可。

#include <lastweapon/number>
using namespace lastweapon;

const int N = int(2e5) + 5;
int A[N]; Int F[N]; map<int, Int> dp[N][3];
int n;

inline Int C(int n, int m){
	return F[n]/(F[m]*F[n-m]);
}

int main(){

#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
#endif

    MOD = 998244353;
	F[0] = 1; FOR(i, 1, N) F[i] = F[i - 1] * i;

	RD(n); REP(i, n) RD(A[i]);
	dp[0][2][A[0]-1] = 1;

	FOR(i, 1, n) REP(a, 3) for(auto it: dp[i-1][a]){
		int x = it.fi; Int u = it.se;
		FOR_1(b, max(0, 1-x), min(a, A[i]-x)) {
			int y = A[i]-x-b;
			dp[i][b][y] += u * C(A[i]-1, y) * C(a, b);
		}
	}

	Int z = 0; REP(i, 3) z += dp[n-1][i][0];
	OT(z);
}

Posted by xiaodao
Category: 日常