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

推荐订阅源

F
Full Disclosure
Stack Overflow Blog
Stack Overflow Blog
H
Help Net Security
Microsoft Azure Blog
Microsoft Azure Blog
The GitHub Blog
The GitHub Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Recorded Future
Recorded Future
Y
Y Combinator Blog
Cloudbric
Cloudbric
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
S
Schneier on Security
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
C
Cybersecurity and Infrastructure Security Agency CISA
TaoSecurity Blog
TaoSecurity Blog
Security Latest
Security Latest
N
News and Events Feed by Topic
Hacker News - Newest:
Hacker News - Newest: "LLM"
D
DataBreaches.Net
Security Archives - TechRepublic
Security Archives - TechRepublic
H
Hacker News: Front Page
C
Cisco Blogs
L
LangChain Blog
aimingoo的专栏
aimingoo的专栏
Recent Commits to openclaw:main
Recent Commits to openclaw:main
V
Vulnerabilities – Threatpost
L
LINUX DO - 最新话题
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Google Online Security Blog
Google Online Security Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
A
About on SuperTechFans
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Jina AI
Jina AI
C
CXSECURITY Database RSS Feed - CXSecurity.com
Schneier on Security
Schneier on Security
T
Tenable Blog
N
News and Events Feed by Topic
W
WeLiveSecurity
有赞技术团队
有赞技术团队
AI
AI
爱范儿
爱范儿
大猫的无限游戏
大猫的无限游戏
Latest news
Latest news
T
The Blog of Author Tim Ferriss
S
Security Affairs
Know Your Adversary
Know Your Adversary
Simon Willison's Weblog
Simon Willison's Weblog
G
GRAHAM CLULEY
Google DeepMind News
Google DeepMind News
The Cloudflare Blog

皓子的小站

网站字体应用之坑——font-family 篇 糟糕的 meta name="theme-color" How to Automatically Track Newly Supported ESLint Rules in Oxlint How to Gradually Migrate from ESLint to Oxlint (Without Breaking Everything) 静态资源预压缩:零运行时开销,极致节省带宽 CVE-2025-70886 Proof of Concept (PoC) | A Script to Crash Halo CMS Comment Backend 自定义网页鼠标指针——一段曲折的旅程 CVE-2025-70886 漏洞复现/PoC | 一个脚本让 Halo CMS 评论后台瘫痪 2025 年终总结 & 博客两周年 老用户专享!已有 Halo 专业版授权可免费升级商业版 自动追踪 Oxlint 对 ESLint 规则的新增支持 Halo 贡献者证书与实体周边盲盒开箱 博客评论系统指南 CDN 回源跟随配置导致登录异常问题排查 SCDN 免费赞助计划:助力高质量博客&博客圈 锐捷校园网:网络共享与带宽叠加方案(哈理工案例) ESLint 到 Oxlint 渐进式迁移快速上手指南 Fixing Vite Breaking Inline JS & CSS in Thymeleaf Templates 解决 Vite 破坏 Thymeleaf 模板内联 JS & CSS 的方法 我的博客,为什么是月更? 博客俱乐部一周年纪念品开箱 网站字体加载之坑——format 篇 经历 1000000000 次 DDoS 请求攻击后,我总结了三条经验 题解分享:[AtCoder Beginner Contest 414 E] Count A%B=C 题解分享:[蓝桥杯 2025 国 Python A] 杨辉三角 P12876 FiF口语训练破解刷分教程(适用于 Windows) 不要与蠢人辩论 小心网络地雷·续篇 当心网络组织“开往”·续篇 当心网络组织“开往” 小心网络地雷 在 Halo CMS 中通过模板实现随机推荐多篇文章 回应某博客上有关“开往”组织在内部会议上对我的污蔑(上) 再遭 DDoS 攻击:CDN 流量限额拦不住请求计费飙升 网站流量分析工具 Umami 中国大陆合规版发布 把握当下,享受生活 Folo 认证功能反成漏洞?警惕 RSS 订阅源所有权被恶意盗取风险 在 Halo CMS 中通过模板实现随机文章跳转功能 从沉默展柜到时代回响:731部队罪证陈列馆参访手记 脚本分享:CDN 流量触顶后自动切换至 Cloudflare 官方 BUG 快薅!Halo 永久/买断用户可额外获得一份买断许可 老用户专享!已有 1Panel 永久授权/买断许可用户可再领免费买断许可证! 限时特惠!1¥ 立即解锁 1Panel 专业版全功能 61 天 混合云架构下的动态 IPv6 智能加速实践:从家庭网络到全球分发的低成本部署指南 如何用 AI 全方面辅助博客创作 - 从博文之内到博文之外 Random Number Generation and Formatting in Thymeleaf Thymeleaf 随机数生成与格式化详解 列举我维护的项目和发布的软件包 快速部署教程 - 通过 Webhook 触发邮件通知的开源自托管服务 Going Against the Grain - Four Websites That Make Your URL Longer 反其道而行 - 四个让你网址变得更长的网站 2024 年终总结 & 博客一周年 基于 OneBot API 的简易异步 QQ 群批量发消息脚本 如何快速完成中文排版优化 如何给文章分类和打标签 群规之敏感违禁词对抗 一图展示​ ​RSS3 世界 - The Open(RSS3) Universe 开源项目发到 bilibili 后可能获得的 PR C/C++:为什么 a[i][j] 等价于 *(*(a+i)+j) Fast Methods to Convert Uppercase Letters to Lowercase in C++ C++ 中快速将字符串大写字母转为小写的方法 Fixing GitHub Actions push to ghcr '403 Forbidden' error Fixing docker pull image "ghcr.io..." Unauthorized error 本站“算法题练习/题解分享”相关文章汇总 不怕流氓多,就怕流氓有文化——站长应该防范的几个问题及对应解决方法分享 题解分享:HRBUST 1132 水数 新手程序员必备的三项技能 如何快速排查插件(模组)的兼容性问题(基于二分法和分治思想) 通过 Umami 最新功能观察定时发布文章的最佳时段 踩坑分享:如何一个人搬运 126.7 斤的书坐动车 两篇文章分享:别像弱智一样提问 & 提问的智慧 论下落式音游/定轨音游中的优质粪铺(文末附铺面推荐) 为什么选择无纸化阅读?为什么买墨水屏电子书?为什么 Kindle“失败”了? 我维护的 Halo 主题,现已发布到 Halo 应用商店! OSU!Standard(osu!std)/OSU!Taiko 转 OSU!Mania 铺面转换器发布 我常用的 OSU!Mania 皮肤分享 电荷守恒辨析:为什么一个离子带多个电荷要乘上所带电荷数而不是除以所带电荷数 注意!align-items: flex-start 会导致 overflow-wrap: break-word 失效 惊人 98 元限定T恤!1Panel, Halo 开发商开启推广积分奖励活动 Minecraft Spigot Bukkit 服务器插件开发 教程收集 中文博客倡议 Windows 10 遇到“只能重装系统”但不想重装的解决方案 Windows 10 文件系统错误 -2144926975 -2147219196 修复 Windows 10 升级 Windows 11 简明教程 CSS 预处理器如何正确的复用样式(stylus 中使用 @extend 继承的坑) 请一定要回复博客下的匿名评论!对于博主和评论者有关匿名评论的倡议 一图解释单一质点运动波动图像和振动图像的关系 解决 Docker pull image "ghcr.io..." Unauthorized error 解决 GitHub Actions push to ghcr '403 Forbidden' error 解决 Umami API 更新延迟问题(如何修改开源项目代码并构建 Docker 镜像-以 Umami 为例) 在国家公祭日自动将网站变灰 中文博客圈列表 解决 Halo CMS 的 Umami Plugin CORS&CSP 跨域报错问题 Windows 创建存储池报错 无法创建池 不支持该请求 (0x00000032) Windows 显示器突然黑白 桌面突然黑白 鼠标和截图还是彩色的 通过指令过滤出正确的公网 IPv6 地址(记一次折腾 IPv6 DDNS) 我的世界免费科技地址 1.7-1.21 网站 Favicon 下载工具发布 键盘 Bios 内可用 系统内无法输入 设备管理器无黄色感叹号 设备管理器 网卡一堆黄色感叹号 例如 WAN, Miniport
2025年团体程序设计天梯赛 - Python 个人赛时暴力题解
HowieHz · 2025-04-19 · via 皓子的小站

前言

第一次参加天梯赛,虽然不是队里分数最低的,也不是第二低的,在队里的位置来说还是拖后腿了。

忘记复制题面了,只有赛事题解。题面有机会后补。

原来想纯用那个网页调试的,但是网页一直无法使用,所以开了 PyCharm。

教训:

  1. 菜就多练,得到了一个符合自己水平的分数。
  2. 用 Python = TLE,本篇出现题解未拿满分都是爆点 TLE。
  3. 看知乎大神说用 Python 在这个比赛容易被卡常,pta 又不开放 PyPy。长个教训,明年应该还会参加,不会再用 Python 了。
  4. 提前开好 IDE:网站调试不一定能用。
  5. 赛前不要喝水:这次比赛前一个小时没法看题面没法提交,然后比赛又延长一个小时,对选手的心态和膀胱来说是一个挑战。

每个代码块开头的注释意为:{实际得分}/{此题总分}

L1-1

签到

# 5/5
print("Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.")

L1-2

签到

# 5/5
a, b, c = map(int, input().split())
print(a + b + c)

L1-3

阅读理解

# 10/10
T, S, t = map(int, input().split())

if T > 35 and t >= 33:
    if S == 0:
        print("Shi Nei")
        print(T)
    else:
        print("Bu Tie")
        print(T)
else:
    if S == 1:
        print("Bu Re")
        print(t)
    else:
        print("Shu Shi")
        print(t)

L1-4

转换为二进制,保留最高位的 1,其余都清 0,再转回十进制,输出答案即可。

# 10/10
print(int("1" + (len(bin(int(input()))[2:]) - 1) * "0", 2))

L1-5

# 15/15
s = input()
l = list(map(int, input().split()))
charmap = {}
sum = 0
for c in s:
    sum += l[ord(c) - ord("a")]
    if c in charmap:
        charmap[c] += 1
    else:
        charmap[c] = 1
# 赛时脑梗,可以直接
# for i in range(ord('a'), ord('z')):
for i in ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y']:
    if i in charmap:
        print(charmap[i], end=" ")
    else:
        print(0, end=" ")
# 不能有行末空格,故单独检查
if "z" in charmap:
    print(charmap["z"])
else:
    print(0)
print(sum)

L1-6

# 10/15
N, M = map(int, input().split())
# 部分 action 需要 str,部分 action 需要 list
# 预先处理为 list,需要时转换为 str 一样 TLE 扣五分
alist_str = input()
for _ in range(M):
    action = int(input())
    if action == 1:
        llist = input()
        llist_str = llist[llist.find(" ") + 1 :]
        llist2 = input()
        llist2_str = llist2[llist2.find(" ") + 1 :]
        if llist_str in alist_str:
            alist_str = alist_str.replace(llist_str, llist2_str, 1)
    elif action == 2:
        new_alist = []
        b = None
        for i in map(int, alist_str.split()):
            if b is None:
                b = i
                continue
            if (b + i) % 2 == 0:
                new_alist.append(b)
                new_alist.append(int((b + i) / 2))
                b = i
            else:
                new_alist.append(b)
                b = i
        new_alist.append(b)
        alist_str = " ".join(map(str, new_alist))
    else:
        index_s, index_e = map(int, input().split())
        alist = list(map(int, alist_str.split()))
        alist = (
            alist[: index_s - 1] + alist[index_s - 1 : index_e][::-1] + alist[index_e:]
        )
        alist_str = " ".join(map(str, alist))
print(alist_str)

L1-7

# 19/20
n = int(input())
s = 0
c = 31
nn = 1
flag = False
passflag = False
while True:
    if not passflag:
        if 1 + 2**c > n:
            s = 0
            c -= 1
            nn = 1
            if c == 0:
                break
            passflag = False
            continue
        else:
            passflag = True
    s += nn**c
    if s < n:
        nn += 1
    elif s == n:
        flag = True
        break
    else:
        s = 0
        c -= 1
        nn = 1
        passflag = False
        continue
if flag:
    for i in range(1, nn):
        print(f"{i}^{c}+", end="")
    print(f"{nn}^{c}")
else:
    print(f"Impossible for {n}.")

L1-8

思路是计算出每行里最大的数字(计算每列最大的数字也一样),将价值和坐标存入数组 line_max。按价值从大到小遍历数组 line_max,记录点的行号和列号,要是出现相同的行号和列号就跳过这个点。

# 15/20
n, m, k = map(int, input().split())
mm = [[[0] for _ in range(m)] for _ in range(n)]
line_max = []

# 读取 + 预处理得出每行最大价值目标
for _ in range(n):
    mm[_] = list(map(int, input().split()))
    max_n = "-INF"
    l = -1
    for index, n in enumerate(mm[_]):
        if max_n == "-INF" or n > max_n:
            max_n = n
            l = index
    line_max.append((max_n, _, l))

c = 0  # 当前攻击数
dead_h = set()  # 记录已摧毁的行号
dead_l = set()  # 记录已摧毁的列号

for point in sorted(line_max, key=lambda a: a[0], reverse=True):
    if c == k:
        # 达到攻击数上限
        break

    # 检查行号和列号是否出现过
    if point[1] in dead_h:
        continue
    if point[2] in dead_l:
        continue

    c += 1
    # 记录行号和列号
    dead_h.add(point[1])
    dead_l.add(point[2])

# 输出时跳过已摧毁的行号和列号
new_mm = []
for index, h in enumerate(mm):
    if index in dead_h:
        continue
    temp_h = []
    for index_2, l in enumerate(h):
        if index_2 in dead_l:
            continue
        temp_h.append(l)
    new_mm.append(temp_h)
for _ in new_mm:
    print(" ".join(map(str, _)))

L2-1

中缀转后缀,然后按计算过程输出,但不输出计算过程中的数。
菜鸡忘了咋写了,现推,最后爆几个 TLE。

# 15/25
s = input()
pc = []
temp = []
sign = ["*", "/", "+", "-"]
end = []
ihave_left = 0
for _ in s:
    if _ not in sign:
        if _ not in ["(", ")"]:
            pc.append(_)
            if ihave_left == 0:
                pc.append(temp.pop())
            continue
        if _ == ")":
            ihave_left -= 1
            pc.append(temp.pop())
            pc.append(")")
            continue
        if _ == "(":
            pc.append("(")
            ihave_left += 1
            continue
    else:
        if pc[-1] in sign and (pc[-1] in ("+", "-") and _ in ("*", "/")):
            temp.append(pc.pop())
        temp.append(_)
while temp:
    pc.append(temp.pop())
ca_list = []
for _ in pc:
    if _ in ("(", ")"):
        continue
    if _ in sign:
        b, b_s = ca_list.pop()
        a, a_s = ca_list.pop()
        print(f"{a if a_s==0 else ''}{_}{b if b_s==0 else ''}")
        ca_list.append((str(eval(f"{a}{_}{b}")), 1))
    else:
        ca_list.append((_, 0))

L2-2

暴力检查

# 16/25
from functools import cmp_to_key

n = int(input())
g0 = set()
g1 = set()
g2 = set()
for _ in range(n):
    x, y = list(map(int, input().split()))
    if y == 0:
        g0.add(x)
    elif y == 1:
        g1.add(x)
    else:
        g2.add(x)
ans = []
for x1 in g0:
    for x2 in g1:
        x3 = x2 + (x2 - x1)
        if x3 in g2:
            ans.append([x1, x2, x3])


def cmp(a, b):
    if a[1] < b[1]:
        return -1
    elif a[1] > b[1]:
        return 1
    else:
        if a[0] < b[0]:
            return -1
        elif a[0] > b[0]:
            return 1
        else:
            return 0


ans.sort(key=cmp_to_key(cmp))
if not ans:
    print(-1)
else:
    for a in ans:
        x1, x2, x3 = a
        print(f"[{x1}, 0] [{x2}, 1] [{x3}, 2]")

其他

L2-3 想读取全部时间,然后分块判断,但没写。
L2-4 写一半

n,a,b=list(map(int,input().split()))

def k(_):
    for c in str(_)[::-2]:
        if c not in ('0', '2', '4', '6', '8'):
            return True
    return False

def k2(_):
    for c in str(_)[-2::-2]:
        if c not in ('0', '2', '4', '6', '8'):
            return True
    return False

for _ in range(a,b+1):
    if n>=10:
        if str(_)[9] != '0':
            continue
    if n>=5:
        if str(_)[4] not in ('0','5'):
            continue
    if len(_)%2==0:
        if k(_):
            continue
    else:
        if k2(_):
            continue
# 未完成

时间把握不当,最后在

  1. 把前面的优化
  2. 重写为 C++
  3. 嫖分
  4. 再写一题

中选择的了选项 4。
从结果来看是最差的选项。

后记

最后总分 120,个人有效分 120。
队里大哥带飞,队伍得分 1457。