# AcWing 蓝桥杯C++ AB组辅导课学习记录（Python，备战蓝桥杯）Day61 - Day86

12 篇文章 4 订阅
10 篇文章 17 订阅

Day 61 (2022.3.14)

Day 62 (2022.3.15)

Day 63 (2022.3.16)

# acwing 2068. 整数拼接
N = 100010
if __name__ == '__main__':
n, k = map(int, input().split())
arr = [0]+[int(x) for x in input().split()]
remainders = [[0]*11 for _ in range(N)]

# 这一步是算a,a^1,a^2..%k的余数并存下来
for i in range(1,n+1):
t = arr[i]%k
for j in range(11):
remainders[t][j] += 1
t = (t*10)%k

# 这一步是算假设数组中的每一个数是b，可以找到相对应合适的a有多少个
res = 0
for i in range(1,n+1):
t, length = arr[i]%k, len(str(arr[i]))
res += remainders[-t%k][length]
# 自己不能和自己凑对
r = (t*10**length)%k
if r==-t%k: res-=1
print(res)

Day 64 (2022.3.17)

# acwing 3416. 时间显示

if __name__ == '__main__':
n = int(input())
days = n//(24*60*60*1000)
hours = (n-days*(24*60*60*1000))//(60*60*1000)
minutes = (n-days*(24*60*60*1000)-hours*60*60*1000)//(60*1000)
seconds = (n-days*(24*60*60*1000)-hours*60*60*1000-minutes*(60*1000))//1000
print("{:0>2d}:{:0>2d}:{:0>2d}".format(hours,minutes,seconds))

# acwing 2875. 超级胶水

if __name__ == '__main__':
n = int(input())
arr = [int(x) for x in input().split()]
res,total = 0,0
for i in range(n):
res += total*arr[i]
total += arr[i]
print(res)

# 动态规划  类似石子合并
# f = [[float('inf')]*(n+1) for _ in range(n+1)]
# for i in range(1,n+1): f[i][i] = 0
#
# for length in range(2,n+1):
#     for i in range(1,n-length+2):
#         j = i+length-1
#         for k in range(i,j):
#             f[i][j] = min(f[i][j], f[i][k]+f[k+1][j]+sum(arr[i:k+1])*sum(arr[k+1:j+1]))
# print(f[1][n])

# 贪心思想
# mindex, mv = 0, float('inf')
# res = 0
# while len(arr)!=1:
#     for i in range(len(arr)-1):
#         if arr[i]*arr[i+1]<mv:
#             mv, mindex = arr[i]*arr[i+1], i
#     res += mv
#     arr.insert(mindex, arr[mindex] + arr[mindex + 1])
#     arr.pop(mindex+1)
#     arr.pop(mindex+1)
#     mv = float('inf')
# print(res)

Day 65 (2022.3.18)

# acwing 3417. 砝码称重
N = 100001
if __name__ == '__main__':
n = int(input())
w = [0]+[int(x) for x in input().split()]
t = sum(w)
f = [[0]*(t+1) for _ in range(n+1)]

f[0][0] = 1
for i in range(1,n+1):
for j in range(t+1):
f[i][j] |= f[i-1][j]
if j + w[i] <= t: f[i][j] |= f[i-1][j+w[i]]
f[i][j] |= f[i - 1][abs(j - w[i])]
print(sum(f[n]))


AcWing 3418. 杨辉三角形 - AcWing

# acwing 3418. 杨辉三角形
# 这道题的思想是从第16斜行循环到第0斜行
# 在每一斜行的起点和终点max（n,2k），从n中任取肯定比n大，所以
# 以这个为终点内范围内如果有n，肯定找得到n

# 这个是阶乘的写法
def C(a,b):
res, i = 1, a
for j in range(1,b+1):
res = res*i//j
if res>n: return res
i -= 1
return res

def check(k):
# l, r = 2 * k, n
# r = max(n,l)
# l和r分别是当前斜行的右上角的横行数和左下角的横行数
# 表示应该在这个范围内找n，讨论最大情况r=n的时候C(n,1)
# 肯定可以为n，最小情况r=l，就是当前斜行的第一个数就是要找的n
# 说实话上面这种代码不容易理解，大佬就是这样，以为很容易懂

if C(2*k,k)>n: return False
# l, r都是指横行行数
l, r = 2*k, n

while l<r:
mid = (l+r)//2
if C(mid,k)>=n: r=mid
else: l=mid+1
if C(r,k)!=n: return False
print((r+1)*r//2+k+1)
return True

if __name__ == '__main__':
n = int(input())
if n==1: print(1)
else:
for k in range(16,0,-1):
if check(k): break


Day 66 (2022.3.19)

# acwing 2069. 网络分析

def find(x):
if x==p[x] or p[p[x]]==p[x]: return p[x]
r = find(p[x])
d[x] += d[p[x]]
p[x] = r
return p[x]

if __name__ == '__main__':
n, m = map(int, input().split())
p, d = [x for x in range(n+1)], [0]*(n+1)
for _ in range(m):
optr, a, b = map(int, input().split())
if optr==1:
aindex, bindex = find(a), find(b)
if aindex!=bindex:
d[aindex] -= d[bindex]
p[aindex] = bindex
else:
aindex = find(a)
d[aindex] +=b

for i in range(1,n+1):
if i==find(i): print(d[i], end=' ')
else: print(d[i]+d[find(i)], end=' ')

AcWing 3419. 双向排序 - AcWing

# acwing 3419. 双向排序

if __name__ == '__main__':
n, m = map(int, input().split())
arr, stk = [0]+[x for x in range(1,n+1)], []

for i in range(m):
p, q = map(int, input().split())
if p==0:
while stk and stk[-1][0]==0:
q = max(stk.pop()[1],q)
while len(stk)>=2 and stk[-2][1]<=q:
stk.pop()
stk.pop()
stk.append([0,q])
else:
if stk:
while stk and stk[-1][0]==1:
q = min(q, stk.pop()[1])
while len(stk)>=2 and stk[-2][1]>=q:
stk.pop()
stk.pop()
stk.append([1,q])

k, l, r = n, 1, n
for i in range(len(stk)):
if stk[i][0]==0:
while r>stk[i][1] and l<=r:
arr[r]=k
r, k = r-1, k-1
else:
while l<stk[i][1] and l<=r:
arr[l] = k
l, k = l + 1, k - 1
if l>r: break

if len(stk)%2==1:
while l<=r:
arr[l]=k
l, k = l+1, k-1
else:
while l <= r:
arr[r] = k
r, k = r - 1, k - 1

for i in range(1,n+1): print(arr[i], end=' ')

Day 67 (2022.3.20)

DP问题首先就要想到通过一个点（条件）来进行集合划分，这样才容易得到合理的状态表示和状态计算（当然y总说的是先状态表示再确定集合划分规则，我这里只是想强调找到这个划分条件，划分点）

（这道题按y总的思想也很容易相同，但是在将思想code的过程中就非常麻烦，没有实现出来，然后题解高赞的几个答案code和想法都很简单直接）

# acwing 4378. 选取数对
# [i][j] 表示到1~i位置，选择j个区间的最大区间和
N = 5010

if __name__ == '__main__':
n, m, k = map(int, input().split())
arr = [0]+[int(x) for x in input().split()]
f = [[0]*N for _ in range(N)]
for i in range(1,n+1): arr[i] += arr[i-1]

for i in range(1,n+1):
for j in range(1,n+1):
if i-m+1<1: f[i][j] = arr[i]
else: f[i][j] = max(f[i-1][j], f[i-m][j-1]+arr[i]-arr[i-m])
print(f[n][k])

# acwing 4378. 选取数对
# Y总思路未优化版本
N = 5010

if __name__ == '__main__':
n, m, k = map(int, input().split())
arr = [0]+[int(x) for x in input().split()]
f = [[0]*N for _ in range(N)]

for i in range(1,n+1): arr[i] += arr[i-1]

for i in range(1,n+1):
for j in range(1,k+1):
if i<=m:
f[i][j] = arr[i]
continue

f[i][j] = f[i-1][j]
l, r = (j-1)*m, i-m+1
for c in range(l, r):
f[i][j] = max(f[i][j], f[c][j-1]+arr[i]-arr[i-m])

res = 0
for i in range(1,n+1): res = max(res, f[i][k])
print(f[n][k])


Day 68 (2022.3.21)

# acwing 3490. 小平方
# 这道题没有说n的一半是取整，你就不要自己取整

if __name__ == '__main__':
n = int(input())
res = 0
for i in range(1,n):
if ((i**2)%n)<(n/2): res+=1
print(res)
# acwing 3492. 负载均衡
# 这道题思路和y总一样，但是只过了7/10，求大神指点

from heapq import *

if __name__ == '__main__':
n, m = map(int, input().split())
h = [[] for _ in range(m+1)]
capacity = [0] + [int(x) for x in input().split()]

for _ in range(m):
a, b, c, d = map(int, input().split())
capacity[computer_num] += pluscapacity
if capacity[b]>=d:
capacity[b]-=d
print(capacity[b])
else: print(-1)

Day 69 (2022.3.22)

AcWing 3494. 国际象棋 - AcWing

# acwing 3494. 国际象棋
# 感觉跟棋格摆放有关的容易使用状态压缩DP，状态数量不能太多，估计不超过30
# 当前位置可以被上一行和上上一行攻击到，所以需要存储两行的状态

N, M, MOD, T = 1<<6, 110, int(1e9)+7, 21

def lowbit(x):
ans = 0
while x:
ans += 1
x -= x&-x
return ans

if __name__ == '__main__':
n, m, k = map(int, input().split())
# f[i][a][b][t] 表示前1~i列已经摆好，i-2列的状态是a，i-1列的状态是b，t为已经摆放的马的数量
f = [[[[0]*T for _ in range(N)] for _ in range(N)] for _ in range(M)]
# 这里有个tips，题目的列不是m吗，但是m范围为1<=m<=100，2^100种状态显然会超时，所以改用n
maxn = 1<<n

f[0][0][0][0] = 1
for i in range(1,m+1):
for a in range(maxn):
for b in range(maxn):
# 判断前前列和前列有没有发生冲突剪枝
if ((a>>2)&b or a&(b>>2)): continue
else:
for c in range(maxn):
# 判断前列和当前列有没有发生冲突
if ((c>>2)&b or c&(b>>2)):continue
# 判断前前列和当前列有没有发生冲突
if ((c>>1)&a or c&(a>>1)):continue
t = lowbit(c)
# 这行已经拿了t个马了，他可以从前面拿tt-t (0~k-t) 个马的状态转移过来
for tt in range(t,k+1):
f[i][b][c][tt] = (f[i][b][c][tt] + f[i-1][a][b][tt-t]) % MOD
res = 0
for i in range(maxn):
for j in range(maxn):
res = (res + f[m][i][j][k]) % MOD
print(res)


IDLE这IDE是真的难用。



t = int(input())
for _ in range(t):
arr = [int(x) for x in input().split()]
length, game = arr[0], arr[1:]
res = 0
for i in range(length):
res ^= game[i]
if res==0:
print(0)
else:
onenums = [0]*21
for i in range(length):
x = game[i]
for j in range(21):
onenums[j] += (x>>j)&1
for i in range(20,-1,-1):
if onenums[i]%2==0: continue
elif onenums[i]==1:
print(1)
break
else:
if (length-onenums[i])%2:
print(-1)
break
else:
print(1)
break


Day 70 (2022.3.23)

# 有除法不能在循环里用取模
# 存在模的之后除为0的情况
MOD = int(1e9+7)

if __name__ == '__main__':
n = int(input())
for _ in range(n):
a, b = map(int, input().split())
j, res = 1, 1
for i in range(a,b,-1):
res = res*i//j%MOD
j += 1
print(res)

Day 71 (2022.3.24)

Day 72 (2022.3.25)

AcWing 3420. 括号序列 - AcWing

# acwing 3420. 括号序列
# 设置cnt变量，从左到右循环，遇到左括号+1，右括号-1，当
# cnt<0, 则必须添加一个左括号。结束后cnt的值就代表需要添加的
# 右括号的数量

# 先添加左括号使得序列合法（左括号大于右括号）
# 再将序列反转，并将左括号换成右括号，右括号换成左括号
# 再添加左括号使得序列合法（其实相当于添加右括号）
# 先添加左括号，再添加右括号，相乘就可以得到答案

MOD = (int)(1e9 + 7)

return (x + y) % MOD

def brackets():
f = [[0 for i in range(n + 10)] for i in range(n + 10)]
f[0][0] = 1

for i in range(1, n + 1):
if str[i] == '(':
for j in range(1, n + 1):
f[i][j] = f[i - 1][j - 1]
else:
f[i][0] = add(f[i - 1][0], f[i - 1][1])
for j in range(1, n + 1):
f[i][j] = add(f[i - 1][j + 1], f[i][j - 1])

for i in range(n + 1):
if f[n][i]:
return f[n][i]

str = list(input())
n = len(str)

str.insert(0, 0)  #使目标字符串下标从 1 开始
ans_l = brackets()

str.reverse()
for i in range(n):
if str[i] == '(':
str[i] = ')'
else:
str[i] = '('
str.insert(0, 0)  #使目标字符串下标从 1 开始
ans_r = brackets()

print(ans_l * ans_r % MOD)


# acwing 3420. 括号序列
M = 1000000007

def brackets():
f = [[0]*(n+10) for _ in range(n+10)]
f[0][0] = 1

for i in range(1,n+1):
if s[i]=='(':
for j in range(1, n + 1):
f[i][j] = f[i-1][j-1]
else:
f[i][0] = (f[i - 1][0] + f[i - 1][1]) % M
for j in range(1, n + 1):
f[i][j] = (f[i-1][j+1]+f[i][j-1]) % M

for i in range(n+1):
if f[n][i]: return f[n][i]

if __name__ == '__main__':
s = [''] + list(input())
n = len(s)-1

l = brackets()
s = [''] + list(reversed(s))

for i in range(1,n+1):
if s[i]==')': s[i]='('
else: s[i]=')'

r = brackets()
print(l * r % M)



Day 73 (2022.3.26)

Day 74 (2022.3.27)

# 贪心加上二分就能做了，b[i]是贪心的去构造，
# 尽可能比b[i−1]大1

def check(x):
barr = arr[:]
barr[0] = max(1, barr[0]-x)
for i in range(1,n):
# 模拟一下样例 7 9 5 1 3 2
if barr[i]+x<=barr[i-1]: return False
if barr[i]-x>barr[i-1]: barr[i] -= x
else: barr[i]=barr[i-1]+1

return True

if __name__ == '__main__':
n = int(input())
arr = [int(x) for x in input().split()]
l, r = 0, int(1e9)
while l<r:
mid = (l+r)//2
if check(mid): r = mid
else: l = mid+1
print(l)

a = [0 for x in range(0, 100005)]
b = [0 for x in range(0, 100005)]

# b[i]表示二进制下的第i位
def update(x):
for i in range(60, -1, -1):
if (x>>i)&1:  # 如果x在二进制表示下含有第i位
if b[i]:
x ^= b[i]
# 如果b[i]存在则让x^b[i],
# 因为之前b[i]也是由已经保存过的a[]数组贡献的
# 所以，这样异或x可以看作x于之前的a[]数组进行异或
# 然后一直异或到为0或者当前b[i]还没有被赋值
else:
b[i] = x
break
# 否则b[i]赋值为x,
# 表示当前二进制下的第i位可以被异或出来，且x的最高位就是i

ans = 0
n = int(input())
line = input().split()
for i in range(1, n + 1):
a[i] = int(line[i - 1])
update(a[i])
# 读入数据对于每一个数字都下放来维护b[i]
for i in range(60, -1, -1):
if (ans ^ (1 << i)) > ans:
ans ^= b[i]
# 贪心的过程，ans看作一个二进制数，从高位开始，如果b[i]存在，
# 肯定优先跟b[i]异或，倒着让小值不会影响到大值
print(ans)


Day 75 (2022.3.28)

# cur是当前是第多少小的数，pre当前计算的前缀为多少
class Solution:
def findKthNumber(self, n, k) -> int:
cur, prefix = 1, 1

while cur < k:
count = self.get_count(prefix,n)
if cur + count > k: prefix, cur = prefix*10, cur+1
else: prefix, cur = prefix+1, cur+count
return prefix

def get_count(self, prefix, n):
count = 0
cur, next = prefix, prefix+1
while cur<=n:
count += min(next,n+1) - cur
cur, next = cur * 10, next * 10
return count

[字节跳动最常考题之一]本题史上最完整具体的手摸手解答，时间效率超越100%用户 - 字典序的第K小数字 - 力扣（LeetCode） (leetcode-cn.com)

Day 76 (2022.3.29)

AcWing 3424. 最少砝码 - AcWing

AcWing 3424. 最少砝码 详细超简解法 - AcWing

# acwing 3424. 最少砝码
# 这道题告诉我，没有思路或者不会做
# 可以从特例开始模拟 n=1,n=2,n=3...

if __name__ == '__main__':
n = int(input())
i = 0
while n>0:
n -= 3**i
i += 1
print(i)

# 选i+1个砝码能表示出的最大值为选i个砝码的3倍+1
if __name__ == '__main__':
n, i, res = int(input()), 0, 0
while i<n:
i, res = i*3+1, res+1
print(res)

# acwing 3422. 左孩子右兄弟

import sys
sys.setrecursionlimit(99999)

global idx
e[idx], ne[idx], h[a], idx = b, h[a], idx, idx+1

# 求以u为根节点的子树深度最高是多少
def dfs(u):
res, bro, idx = 1, 0, h[u]

while idx!=-1:
bro, b = bro+1, e[idx]
res = max(dfs(b), res)
idx = ne[idx]

res += bro
return res

if __name__ == '__main__':
n = int(input())
h, e, ne, idx = [-1]*(n+1), [0]*(n+1), [0]*(n+1), 0
for i in range(2,n+1):
a = int(input())
print(dfs(1)-1)
# acwing 3422. 左孩子右兄弟

if __name__ == '__main__':
n = int(input())
# f[i]表示i节点的最大高度（不包括i节点本身），tree[i]表示i节点的父亲是谁
# children[i]表示i节点有几个儿子
f, tree, children = [0]*(n+1), [0]*(n+1), [0]*(n+1)

for i in range(2,n+1):
tree[i] = int(input())
for i in range(2,n+1):
children[tree[i]] += 1
# i节点父亲的高度等于max(i节点的高度+他兄弟的数量, i节点父亲现在的高度)
for i in range(n,0,-1):
f[tree[i]] = max(f[tree[i]], f[i] + children[tree[i]])
print(f[1])

Day 77 (2022.3.30)

# 第十二届蓝桥杯 直线

if __name__ == '__main__':
s, points = set(), []

for i in range(20):
for j in range(21):
points.append((i,j))

for i in range(len(points)):
for j in range(i+1,len(points)):
x1, y1 = points[i]
x2, y2 = points[j]
else:
a = (y2-y1)/(x2-x1)
b = y1-(y2-y1)*x1/(x2-x1)
# 向偶数靠拢 round(6.5) == 6
print(len(s))



Day 78 (2022.3.31)

Day 79 (2022.4.1)

Day 80 (2022.4.2)

Day 81 (2022.4.3)

Day 82 (2022.4.4)

Day 83 (2022.4.5)

# HJ16 购物单
# 0：主件，1：主件+附件1，主件+附件2，主件+附件1+附件2

if __name__ == '__main__':
n, m = map(int, input().split())
n //= 10
items = [[[0]*2 for _ in range(4)] for _ in range(m+1)]

for i in range(1,m+1):
v,p,q = map(int, input().split())
v //= 10
if q==0: items[i][0][0], items[i][0][1] = v, v*p
elif not items[q][1][0]: items[q][1][0], items[q][1][1] = v, v*p
else: items[q][2][0], items[q][2][1] = v, v*p

arr = [[[0]*2 for _ in range(4)] for _ in range(m+1)]
for i in range(1,m+1):
arr[i][0][0], arr[i][0][1] = items[i][0][0], items[i][0][1]
arr[i][1][0], arr[i][1][1] = items[i][0][0] + items[i][1][0], items[i][0][1] + items[i][1][1]
arr[i][2][0], arr[i][2][1] = items[i][0][0] + items[i][2][0], items[i][0][1] + items[i][2][1]
arr[i][3][0], arr[i][3][1] = items[i][0][0] + items[i][1][0] + items[i][2][0], items[i][0][1] + items[i][1][1] + items[i][2][1]

f = [[0] * (n + 1) for _ in range(m + 1)]
for i in range(1, m + 1):
for k in range(1, n + 1):
f[i][k] = f[i - 1][k]
if k - arr[i][0][0] >= 0:
f[i][k] = max(f[i][k], f[i - 1][k - arr[i][0][0]] + arr[i][0][1])
if k - arr[i][1][0] >= 0:
f[i][k] = max(f[i][k], f[i - 1][k - arr[i][1][0]] + arr[i][1][1])
if k >= arr[i][2][0]:
f[i][k] = max(f[i][k], f[i - 1][k - arr[i][2][0]] + arr[i][2][1])
if k >= arr[i][3][0]:
f[i][k] = max(f[i][k], f[i - 1][k - arr[i][3][0]] + arr[i][3][1])

res = 0
for i in range(1,m+1):
res = max(f[i][n],res)
print(res * 10)

# f = [[[0] * (n + 1) for _ in range(4)] for _ in range(m + 1)]
# for i in range(1,m+1):
#     for j in range(4):
#         for k in range(1,n+1):
#             f[i][j][k] = f[i-1][j][k]
#             if k - arr[i][0][0]>=0:
#                 f[i][j][k] = max(f[i][j][k], f[i-1][0][k - arr[i][0][0]] + arr[i][0][1])
#             if k - arr[i][1][0]>=0:
#                 f[i][j][k] = max(f[i][j][k], f[i - 1][1][k - arr[i][1][0]] + arr[i][1][1])
#             if k >= arr[i][2][0]:
#                 f[i][j][k] = max(f[i][j][k], f[i - 1][2][k - arr[i][2][0]] + arr[i][2][1])
#             if k >= arr[i][3][0]:
#                 f[i][j][k] = max(f[i][j][k], f[i - 1][3][k - arr[i][3][0]] + arr[i][3][1])
#
# res = 0
# for i in range(1,m+1):
#     for j in range(4):
#         res = max(res, f[i][j][n])
# print(res*10)


# HJ17 坐标移动

if __name__ == '__main__':
s = input().split(';')
point = [0,0]
for i in range(len(s)):
if (len(s[i])==2 and str.isalpha(s[i][0]) and str.isdigit(s[i][1])) \
or (len(s[i])==3 and str.isalpha(s[i][0]) and str.isdigit(s[i][1]) and str.isdigit(s[i][2])):
direction, step = s[i][0], int(s[i][1:])
if direction == 'A':
point[0] -= step
elif direction == 'S':
point[1] -= step
elif direction == 'D':
point[0] += step
elif direction == 'W':
point[1] += step
print('{:d},{:d}'.format(point[0], point[1]))
# HJ18 识别有效的IP地址和掩码并进行分类统计
from sys import *

# 5表示错误IP地址,7为其它类型，0为A，1为B，2为C，3为D，4为E
def typeOfNetwork(num):
numInt = int(num,2)
if numInt >= int(net[0][0],2) and numInt <= int(net[0][1],2): return 0
if numInt >= int(net[1][0],2) and numInt <= int(net[1][1],2): return 1
if numInt >= int(net[2][0],2) and numInt <= int(net[2][1],2): return 2
if numInt >= int(net[3][0],2) and numInt <= int(net[3][1],2): return 3
if numInt >= int(net[4][0],2) and numInt <= int(net[4][1],2): return 4
return 7

def isPrivateNetwork(num):
numInt = int(num,2)
if numInt >= int(privateNet[0][0],2) and numInt <= int(privateNet[0][1],2): return True
if numInt >= int(privateNet[1][0],2) and numInt <= int(privateNet[1][1],2): return True
if numInt >= int(privateNet[2][0],2) and numInt <= int(privateNet[2][1],2): return True
return False

flag = False
for i in range(32):
if masks[i]=='0' and not flag: flag=True
flag = False
break
return flag

def transform(type):
start, end = type[0], type[1]
listStart, listEnd = start.split('.'), end.split('.')
sStart, sEnd = '', ''
for iS in listStart:
if iS == '' or iS == '0':
sStart += '00000000'
else:
sStart += '{:0>8b}'.format(int(iS))
for iE in listEnd:
if iE == '' or iE == '0':
sEnd += '00000000'
else:
sEnd += '{:0>8b}'.format(int(iE))
return [sStart, sEnd]

if __name__ == '__main__':
cnt = [0]*8
net = [['1.0.0.0', '126.255.255.255'],['128.0.0.0', '191.255.255.255'],['192.0.0.0', '223.255.255.255'],['224.0.0.0', '239.255.255.255'],['240.0.0.0', '255.255.255.255']]
privateNet = [['10.0.0.0', '10.255.255.255'], ['172.16.0.0', '172.31.255.255'], ['192.168.0.0', '192.168.255.255']]
for i in range(5):
net[i] = transform(net[i])
for i in range(3):
privateNet[i] = transform(privateNet[i])

while True:
if not s: break

if ('' in network_tmp.split('.')) or ('' in mask_tmp.split('.')):
cnt[5] += 1
continue

t = typeOfNetwork(network)
if t==7:
cnt[7] += 1
continue
cnt[5] += 1
continue
cnt[t] += 1
if isPrivateNetwork(network): cnt[6] += 1

for i in range(7): print(cnt[i], end=' ')


# HJ19 简单错误记录

from sys import *
from collections import *

if __name__ == '__main__':
q = deque()
d = defaultdict(int)

while True:
if not s: break
directory, lines = s.split()
item = (directory.split('\\')[-1][-16:], int(lines))
if item not in q: q.append(item)
d[item] += 1

while len(q)>8: q.popleft()
while q:
item = q.popleft()
print(item[0], item[1], d[item])

Day 84 (2022.4.6)

Day 85 (2022.4.7)

这道题拓扑排序没想出来，百度的宽度搜索也没正确。。不想了

Day 86 (2022.4.8)

--------------------------------------------------------------------------------------

• 3
点赞
• 5
收藏
觉得还不错? 一键收藏
• 打赏
• 0
评论
09-06 2129
02-24 384
06-04 281

### “相关推荐”对你有帮助么？

• 非常没帮助
• 没帮助
• 一般
• 有帮助
• 非常有帮助

ZengXincs

¥2 ¥4 ¥6 ¥10 ¥20

1.余额是钱包充值的虚拟货币，按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载，可以购买VIP、C币套餐、付费专栏及课程。