n,m = map(int,input().split()) from collections import defaultdict d = defaultdict(int) p = dict() for i in range(n): a,b = input().split() d[a] += int(b) input() for i in range(m): name,x,y = input().split() if x == 'order': if d[y] > 0: if name in p: print('no') continue d[y] -= 1 p[name] = (x,y) print('yes') continue else: print('no') continue elif x == 'release': if name not in p: print('no') continue if p[name][1] == y: d[y] += 1 # p.pop(name) del p[name] print('yes') else: print('no') continue
我的代码,我经常在赛码上碰到这种问题,我觉得这第一题就是简单地模拟,大家应该都没问题。
顺带求第三题代码
算法岗
全部评论
(3) 回帖