-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
47 lines (38 loc) · 945 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import math
import os
import random
import re
import sys
from collections import Counter
def freqQuery(queries):
count = Counter()
f = Counter()
lst = []
for i in queries:
if i[0] == 1:
f[count[i[1]]] -= 1
count[i[1]] += 1
f[count[i[1]]] += 1
elif i[0] == 2:
if count[i[1]] == 0:
continue
f[count[i[1]]] -= 1
count[i[1]] -= 1
f[count[i[1]]] += 1
else:
if f[i[1]] == 0:
lst.append(0)
else:
lst.append(1)
return lst
if __name__ == '__main__':
input_file = str(sys.argv[1])
f = open(input_file, "r")
n = int(f.readline().rstrip())
queries = []
for _ in range(n):
s = f.readline().strip()
queries.append(list(map(int, s.rstrip().split())))
ans = freqQuery(queries)
for i in ans:
print(i)