爬山题 import Queue as queue n, m = raw_input().strip().split() n = int(n) m = int(m) x, y = raw_input().strip().split() x = int(x) - 1 y = int(y) - 1 mm = [] visit = [] for _ in range(n): tem = raw_input().strip().split() tem = list(map(int, tem)) mm.append(tem) q = queue.Queue() saber1 = (x, y, mm[x][y]) q.put(saber1) visit.append((x, y)) mh = mm[x][y] while(not q.empty()): cx, cy, ch = q.get() if ch>=mh: mh=ch if cx-1>=0 and mm[cx-1][cy]>=ch: q.put((cx-1, cy, mm[cx-1][cy])) if cx+1<n and mm[cx+1][cy]>=ch: q.put((cx+1, cy, mm[cx+1][cy])) if cy-1>=0 and mm[cx][cy-1]>=ch: q.put((cx, cy-1, mm[cx][cy-1])) if cy+1<n and mm[cx][cy+1]>=ch: q.put((cx, cy+1, mm[cx][cy+1])) print(mh) 第二题直接print 120通过了10%(捂脸)
点赞 2

相关推荐

04-10 11:56
如皋中学 Java
高斯林的信徒:双c9能简历挂的?
点赞 评论 收藏
分享
04-27 08:59
常州大学 Java
牛客139242382号:《两门以上汇编语言》
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务