import random lists 5000 500000 random randrange 5000 random randrange

 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
import random
lists = [[5000, 500000]] + [[random.randrange(0, 5000), random.randrange(0, 5000)] for i in range(500000)]
field = [ [0 for k in range(int(lists[0][0]))] for j in range(int(lists[0][0]))]
x_coord = {}
y_coord = {}
for i in lists[1:]:
if i[0] in x_coord:
x_coord[i[0]] += 1
else:
x_coord[i[0]] = 1
if i[1] in y_coord:
y_coord[i[1]] += 1
else:
y_coord[i[1]] = 1
for line, damage in x_coord.items():
for target in range(lists[0][0]):
field[line][target] = damage
for line2, damage2 in y_coord.items():
for target2 in range(lists[0][0]):
field[target2][line2] += damage2
for duplicate in lists[1:]:
field[duplicate[0]][duplicate[1]] -=1