当前位置: 首页> 汽车> 新车 > 简易软件开发工具_html访问人数统计代码_sem公司_排名seo公司哪家好

简易软件开发工具_html访问人数统计代码_sem公司_排名seo公司哪家好

时间:2025/7/11 7:55:03来源:https://blog.csdn.net/qq_63432403/article/details/143495254 浏览次数: 0次
简易软件开发工具_html访问人数统计代码_sem公司_排名seo公司哪家好

【模板】堆 (nowcoder.com)

import heapq
t = int(input())
class A:__slots__ = 'a'def __init__(self, a):self.a = adef __lt__(self, rhs:'A'):return self.a > rhs.a
hq = []
for _ in range(t):str = input().split()if len(str) == 2:heapq.heappush(hq, A(int(str[1])))else:if str[0] == 'pop' and hq:print(heapq.heappop(hq).a)else:if hq:print(hq[0].a)else:print('empty')

【模板】循环队列 (nowcoder.com)

from collections import deque
dq = deque()
lgh, t = map(int, input().split())
for _ in range(t):s = input().split()if len(s) == 2:if len(dq) == lgh:print('full')else:dq.append(int(s[1]))if s[0] == 'pop':if len(dq) == 0:print('empty')else:print(dq.popleft())if s[0] == 'front':if len(dq) == 0:print('empty')else:print(dq[0])

【模板】链表 (nowcoder.com)

t = int(input())
a = []
for _ in range(t):s = input().split()if s[0] == 'insert':x, y = int(s[1]), int(s[2])if x in a:a.insert(a.index(x), y)else:a.append(y)elif s[0] == 'delete':x = int(s[1])if x in a:a.remove(x)
print( ' '.join(map(str, a))  if a else 'NULL' )

【模板】栈 (nowcoder.com)

from collections import deque
stk = deque()
t = int(input())
for _ in range(t):s = input().split()if s[0] == 'push':stk.append(s[1])elif s[0] == 'pop':if stk:print(stk.pop())else: print('error')elif s[0] == 'top':if stk:print(stk[-1])else:print('error')

【模板】队列 (nowcoder.com)

from collections import deque
q = deque()
t = int(input())
for _ in range(t):s = input().split()if s[0] == 'push':q.appendleft(int(s[1]))elif s[0] == 'pop':if q:print(q.pop())else:print('error')elif s[0] == 'front':if q:print(q[-1])else:print('error')

【模板】并查集 (nowcoder.com)

n,m = map(int, input().split())
p = [ _ for _ in range(n + 1)]
sz = [1] * (n + 1)
def find(x):if x == p[x]:return xp[x] = find(p[x])return p[x]
def union(x, y):x = find(x)y = find(y)if x == y:returnif sz[x] < sz[y]:x, y = y, xp[y] = xsz[x] += sz[y]
for _ in range(m):a,b = map(int, input().split())union(a,b)
for i in range(1, n + 1):find(i)
print(len(set(p)) - 1, max(sz))
关键字:简易软件开发工具_html访问人数统计代码_sem公司_排名seo公司哪家好