1 1 0.7 0.2 0.8 第 3 题感觉要滑动窗口加建树 第 4 题调了半天没过,白嫖 然后最后30分钟想到思路了没写出来 第 5 题没用缓存只过了0.8,难顶 时间都去做第4题了 ```python from collections import defaultdict n,m = list(map(int,input().strip().split(' '))) weigh = list(map(int,input().strip().split(' '))) weigh = [0]+weigh memo = defaultdict(list) for i in range(m): x1,x2= list(map(int,input().strip().split(' '))) memo[x1].append(x2) memo[x2].append(x1) res =[0] memodict = {} def dfs(node,lengh): if node in memodict: return memodict[node] ans = 1 for i in memo[node]: if weigh[i]<weigh[node]: tmp = dfs(i,lengh+1)+1 ans = max(ans,tmp) memodict[node] = ans return ans for i in range(1,n+1): res = max(dfs(i,1),res) print(res[0]) ``` 这是考完写的有缓存版
1 1

相关推荐

不愿透露姓名的神秘牛友
07-07 11:35
程序员小白条:话太多,没实力和学历,差不多回答回答就行了,身份地位不一样
点赞 评论 收藏
分享
06-11 17:39
门头沟学院 Java
小呆呆的大鼻涕:卧槽,用户彻底怒了
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务