-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhashmap1
More file actions
34 lines (34 loc) · 1011 Bytes
/
hashmap1
File metadata and controls
34 lines (34 loc) · 1011 Bytes
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
n, q = map(int, input().split())
a = [0] * n
for i in range(n):
a[i] = []
for i in range(q):
zapros = list(map(str, input().split()))
if zapros[0] == "add":
est = False
for j in range(len(a[int(zapros[1]) % n])):
if a[int(zapros[1]) % n][j] == zapros[1]:
est = True
if not est:
a[int(zapros[1]) % n].append(zapros[1])
print(len(a[int(zapros[1]) % n]))
if zapros[0] == "find":
est = False
for j in range(len(a[int(zapros[1]) % n])):
if a[int(zapros[1]) % n][j] == zapros[1]:
est = True
if est:
print(1)
else:
print(0)
if zapros[0] == "remove":
est = False
for j in range(len(a[int(zapros[1]) % n])):
if a[int(zapros[1]) % n][j] == zapros[1]:
est = True
a[int(zapros[1]) % n].pop(j)
break
if est:
print(1)
else:
print(0)