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

推荐订阅源

N
News and Events Feed by Topic
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
月光博客
月光博客
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
大猫的无限游戏
大猫的无限游戏
T
Tailwind CSS Blog
S
SegmentFault 最新的问题
V
V2EX
阮一峰的网络日志
阮一峰的网络日志
C
Cisco Blogs
博客园 - 叶小钗
P
Privacy International News Feed
Jina AI
Jina AI
Apple Machine Learning Research
Apple Machine Learning Research
T
Threatpost
IT之家
IT之家
博客园 - 聂微东
Know Your Adversary
Know Your Adversary
Help Net Security
Help Net Security
罗磊的独立博客
I
Intezer
S
Schneier on Security
博客园_首页
C
CERT Recently Published Vulnerability Notes
雷峰网
雷峰网
Cisco Talos Blog
Cisco Talos Blog
宝玉的分享
宝玉的分享
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Webroot Blog
Webroot Blog
TaoSecurity Blog
TaoSecurity Blog
MyScale Blog
MyScale Blog
P
Privacy & Cybersecurity Law Blog
T
The Exploit Database - CXSecurity.com
PCI Perspectives
PCI Perspectives
Security Latest
Security Latest
H
Heimdal Security Blog
S
Secure Thoughts
Hacker News: Ask HN
Hacker News: Ask HN
Y
Y Combinator Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Microsoft Security Blog
Microsoft Security Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
SecWiki News
SecWiki News
The GitHub Blog
The GitHub Blog
A
Arctic Wolf
A
About on SuperTechFans
aimingoo的专栏
aimingoo的专栏
T
Threat Research - Cisco Blogs
Engineering at Meta
Engineering at Meta
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC

Benson's blog

Enjoy life Internship AI on academic research How AI Will Change the Mobile Ecosystem Look ahead Goodbye 2025 Hacker News to Kindle Another project How to imporve english Introduction of Fraud detection PopTranslate Last day in netease Better idea between Copilot-typed and CLI-typed assistant Gemini-cli LLM Post-Training experience Papers I readed recently about LLM application Difference between LLMs and traditional computer technology GRPO Weekly-#26 AI Application Weekly-#25 AI infra and application Weekly-#24 First week as LLM inference engineer Weekly-#23 seeking job Weekly-#22 2025 New Year AutoSwitch Translate Goodbye 2024 Weekly-#20 Breaking of glass Cross Entropy Loss of Triton Weekly-#18 Cross Entropy Loss of Triton Weekly-#17 Triton Puzzles Weekly-#16 AutoBuilder Weekly-#15 Starting of tanble tennis Weekly-#14 Accident in life Weekly-#13 Trying of xiaohongshu Weekly-#12 summary of LLM acceleration Outline of LLM acceleration Weekly-#11 Copilot-type products Weekly-#10 Preparation for next journey Weekly-#9 Startup of YouTube Notes of flash-attention How to learn knowledge in new fields? Weekly-#8 Start Reading Notes of LoRA Acceleration of LLM - Matrix Multiplication Weekly-#8 Summary for two month Weekly-#7 Staying home Weekly-#6 Cost of PopTranslate Weekly-#5 Updating of PopTranslate Validated example of LLM acceleration Weekly-#4 First insight of LLM accelerate Weekly-#3 PopTranslate Weekly-#2 The fail of first product Weekly-#1 First week of indie develop slack迁移discord 雅思备考 2024Q3 中文博客合集 English Diary in May 五一游记 开始休假 离职前的状态 2024-01-01 duckdb 看懂的第一个PR learning english in October learning english in September learning english in August top hack news 收集 大模型调研 自动驾驶的小玩具 旅游 扬州+苏州 small talk of learning english 新年新气象-碎碎念 刷剧 感染新冠 强化学习简介 神经网络解释性 全局的模型无关解释方法合集 社区发现算法概览 图神经网络入门(GNN) 我的第一款 iOS APP 人的信息输入方式对比 重叠社区检测 人穷极一生到底在追求什么 重拾生活规划 社区发现算法 - Louvain 《幸福的方法》 读《人类简史》有感 妙峰山骑行 黑客帝国 特征交互 特征工程 累计局部效应图 模型解释性-PDP 模型解释性 Web3 入门科普 总结 2022.4 孪生网络做 query 相似度任务 学习 2022.4 Imagen DeBERTa 读论文 用CNN做query相似度任务
AtCoder Beginner Contest 268
Benson · 2022-09-11 · via Benson's blog

想打比赛的时候刚好 AtCoder 有场比赛在进行,就加入了,有两道题目挺有意思的。

E - Chinese Restaurant (Three-Star Version)

题目链接:https://atcoder.jp/contests/abc268/tasks/abc268_e

问题:n个人围在一个圆桌上,每人前面有一个带有编号的盘子,p[i] 代表第i个人前面盘子的编号,编号范围[0, n-1],不重复,每个人的惩罚为跟自己有相同编号的盘子和自己之间的距离。你可以顺时针移动所有盘子任意次(保证盘子之间的相对顺序不变),使得所有人的总惩罚最小,问最小惩罚是多少?

案例:如下图,顺时针移动3个单位获得最小惩罚,惩罚为2

思路:求初始状态下,每个人的盘子和自己的距离,绘制距离和惩罚之间的关系,是一个单峰的函数,当盘子进行旋转时,该函数不断向右移动,如下图中 黑色->红色->蓝色的移动,此时左侧的递增部分惩罚减小一个单位,右侧递减部分惩罚增加一个单位,be1, en1, be2, en2 为惩罚减少和增加的端点,根据人数的奇偶性不同,最大值可能是一个或两个,端点可能会变化一个单位,如下两个图对比:

初始的惩罚可以在 O(N) 复杂度内计算,每次移动时,可以根据前缀和求得实际距离在两个区间内的人数,每次移动的复杂度为 O(1),则整体的时间复杂度为 O(N)

代码:https://atcoder.jp/contests/abc268/submissions/34763908

F - Best Concatenation

题目链接:https://atcoder.jp/contests/abc268/tasks/abc268_f 描述:定义字符串只包含 0-9 和 ‘X’,每个字符串的得分为:针对每个不为 ‘X’ 的字符,当前得分为该字符左侧 ‘X’ 的数量 * 当前字符的数字大小,对每个得到求和即为字符串得分,比如 “XXX1X359” 的得分为 3 * 1 + 4 * 3 + 4 * 5 + 4 * 9 = 71。

给定n个字符串,将n个字符串随意排列后拼接,使得拼接后的新字符串得分最大。

案例:给定三个字符串

1X3

59

XXX

得分最大的拼接方式为:XXX1X359,最大得分71

思路:按照得分逻辑,对所有字符串进行排序,排序后的顺序即为使得得分最大的顺序。 如果只有两个字符串,比较好理解,那多个为什么也满足这个逻辑呢?盲猜的,不知道要怎么证明。。。

代码:https://atcoder.jp/contests/abc268/submissions/34774715

小结

E题并不是比赛时间内解出来的,赛中写了半天的线段树发现思路错了,赛后看大佬代码没看懂,但启发了这个解法。果然,我这个水平的瓶颈还是在解题思路和实现速度上,并不是一些复杂的算法。