牛客856751393号
牛客856751393号
全部文章
分类
归档
标签
去牛客网
登录
/
注册
牛客856751393号的博客
全部文章
(共24篇)
题解 | 小红的好排列
def ksm(a, b): # 快速幂 计算 a ** b res = 1 while b: if b & 1: res = res * a % MOD a = a * a % MOD b >...
2025-03-14
1
19
题解 | 小红的01子序列计数(hard)
while True: try: n = int(input()) s = input() s = ' ' + s + s # 加一个空格,从索引1开始处理 MOD = 10 ** 9 + 7 ans =...
2025-03-14
0
33
题解 | 在树上游玩
from sys import stdin from collections import defaultdict # 计算从某个被标记的节点出发,不需要染色就能够到达的未被标记节点的数量 def dfs(node, parent): # (当前访问的节点, 当前节点的父节点) vis...
2025-03-14
0
16
题解 | 乘之
# 其中一个人为了避免:另外一个人扩充区间后,使得结果会变大或变小;直接选中整个区间 import sys while True: try: input = sys.stdin.read data = list(map(int, input().split(...
2025-03-12
0
24
题解 | 计树
from collections import deque import sys while True: try: input = sys.stdin.read data = input().split() n = int(data[0])...
2025-03-12
0
15
题解 | 1or0
和C++版输出结果一致,但提交不通过。 # 区间内自审值之和即该区间内包含1的连续子串的个数 while True: try: n = int(input()) s = input() q = int(input()) dp =...
2025-03-12
0
19
题解 | 隐匿社交网络
超时了 def find(a): if p[a] != a: p[a] = find(p[a]) # 查找父节点 return p[a] def merge(a, b): # 合并两个集合 pa = find(a) pb = fi...
2025-03-11
0
17
题解 | 小红走网格
from math import gcd while True: try: T = int(input()) for _ in range(T): x, y, a, b, c, d = map(int, input().split()...
2025-03-11
0
28
题解 | 数独数组
from collections import defaultdict while True: try: n = int(input()) num = list(map(int, input().split())) d = defaultdi...
2025-03-11
1
33
题解 | 而后单调
def solve(num, m): n = len(num) dp = [0] * n # 表示以当前字符结尾的连续严格递增子数组的长度 dp[0] = 1 for i in range(1, n): if num[i] > num...
2025-03-10
0
20
首页
上一页
1
2
3
下一页
末页