Last active
April 7, 2022 19:16
-
-
Save pcchou/56037d280d4ecaebdd78837e20f2bf41 to your computer and use it in GitHub Desktop.
3035 bearrrrrrrro的綽號們
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
n = int(input()) | |
dic = {} | |
for _ in range(n): | |
inputs = input().split() | |
op = int(inputs[0]) | |
if op == 1: | |
nickname = inputs[1] | |
if nickname in dic: | |
dic[nickname] += 1 | |
else: | |
dic[nickname] = 1 | |
elif op == 2: | |
nickname = inputs[1] | |
if nickname in dic: | |
dic[nickname] -= 1 | |
if dic[nickname] == 0: | |
del dic[nickname] | |
elif op == 3: | |
ans = list(dic.items()) | |
ans.sort() | |
for key, value in ans: | |
print(key, value) | |
elif op == 4: | |
print(len(dic)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment