牛客459000288号
牛客459000288号
全部文章
分类
题解(9)
归档
标签
去牛客网
登录
/
注册
牛客459000288号的博客
全部文章
(共56篇)
题解 | 密码截取 | Python3 人拉车 | O(n)
# Input and preprocess. s = input() sa = f"#{'#'.join(s)}#" saLen = len(sa) # Manacher algo. center = 0 maxRight = 0 resStart = 0 resLen = ...
2026-01-16
0
40
题解 | 字符串加解密 | Python 查询表
s, t = input(), input() # Algo A = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" B = "1234567890BCDEFGHIJKLMNOPQRST...
2026-01-16
0
42
题解 | 喜欢切数组的红 | Python3 奇技淫巧
# Process input n = int(input()) arr = list(map(int, input().split())) # Algo total = sum(arr) if total % 3 != 0: print(0) exit() chip = tota...
2026-01-14
0
39
题解 | 公共子串计算 | Python DP O(m*n)
s, t = input(), input() # DP # 阶段:s第i个字符,t第j个字符 # 状态:以s[i]结尾和t[j]结尾的公共子串长度 m, n = len(s)+1, len(t)+1 dp = [0]*n maxLen = 0 for i in range(1, m): ...
2026-01-14
0
35
题解 | 隐匿社交网络 | PyPy3(Python3) | 318ms
T = int(input()) for _ in range(T): n = int(input()) arr = map(int, input().split()) # Detect connections x2accounts = {} for...
2026-01-14
0
33
题解 | Redraiment的走法
# Process input n = int(input()) arr = list(map(int, input().split())) # DP # 阶段:起点为i,终点为j # 状态:从i到j走过的最大梅花桩数量 dp = [1] * n for j in range(n): fo...
2026-01-13
0
23
题解 | 计算字符串的编辑距离
# Process input s, t = input(), input() # DP m, n = len(s), len(t) # - 阶段:s前i个字符,t前j个字符 # - 状态:将t前j个字符序列编辑为和s前i个字符序列相同所需最少操作次数 dp = [[1e10] * (n+1) f...
2026-01-13
0
28
题解 | 气球谜题 | 逻辑参考大佬思路,但优化了空间复杂度
# Process input n = int(input()) ac = list(map(int, input())) at = list(map(int, input().split())) # DP # - 阶段:前i个气球 # - 状态:气球排列 0, 1, 2, 01, 02, 10,...
2026-01-13
0
28
题解 | 高精度整数加法 | Python Makes World Better
print(int(input()) + int(input()))
2026-01-10
0
30
题解 | ???
T = int(input()) for _ in range(T): s, t = input(), input() j = 0 bFound = False arr = list(s) for i in range(len(s)): chs...
2026-01-10
0
24
首页
上一页
1
2
3
4
5
6
下一页
末页