|
| 1 | +from collections import * |
| 2 | +import time |
| 3 | +from itertools import * |
| 4 | +from functools import * |
| 5 | +# import networkx as nx |
| 6 | +import re |
| 7 | +import sys |
| 8 | +sys.setrecursionlimit(1000000) |
| 9 | + |
| 10 | +s1 = s2 = 0 |
| 11 | +# coords = {x+1j*y: c for y, r in enumerate(open(0)) for x, c in enumerate(r.strip())} |
| 12 | + |
| 13 | +d4 = [1, 1j, -1, -1j] |
| 14 | +d8 = d4 + [1+1j, 1-1j, -1+1j, -1-1j] |
| 15 | +d4half = [i/2 for i in d4] |
| 16 | +d8half = [i/2 for i in d8] |
| 17 | +def adjacent(coord, dirs=d4): |
| 18 | + return [coord + d for d in dirs] |
| 19 | + |
| 20 | + |
| 21 | + |
| 22 | + |
| 23 | +X = 101 |
| 24 | +Y = 103 |
| 25 | +# X = 11 |
| 26 | +# Y = 7 |
| 27 | +maps = [] |
| 28 | +for line in open(0): |
| 29 | + x, y, vx, vy = map(int, re.findall(r"-?\d+", line)) |
| 30 | + maps.append((x, y, vx, vy)) |
| 31 | +8 |
| 32 | +70 |
| 33 | +284 |
| 34 | + |
| 35 | +seen = set() |
| 36 | + |
| 37 | +for i in range(0, X * Y, 1): |
| 38 | + counts = {} |
| 39 | + quadrant = [0, 0, 0, 0] |
| 40 | + nines = [0] * 9 |
| 41 | + rows = Counter() |
| 42 | + for x, y, vx, vy in maps: |
| 43 | + nx = (x + vx * i) % X |
| 44 | + ny = (y + vy * i) % Y |
| 45 | + if (nx, ny) not in counts: |
| 46 | + counts[(nx, ny)] = 0 |
| 47 | + counts[(nx, ny)] += 1 |
| 48 | + rows[ny] += 1 |
| 49 | + # print(x, y, nx, ny) |
| 50 | + # print(nx, (nx >= 55) + (ny >= 56) * 2) |
| 51 | + # print(X // 2, Y // 2) |
| 52 | + if nx != X // 2 and ny != Y // 2: |
| 53 | + q = (nx > X//2) + (ny > Y//2) * 2 |
| 54 | + #print(q) |
| 55 | + quadrant[q] += 1 |
| 56 | + n = (nx // (X//3+1)) + (ny // (Y//3+1)) * 3 |
| 57 | + # print(n) |
| 58 | + nines[n] += 1 |
| 59 | + seen.add((tuple(sorted(quadrant)), i)) |
| 60 | + |
| 61 | + |
| 62 | + # key = tuple(counts.items()) |
| 63 | + # if key in seen: |
| 64 | + # break |
| 65 | + # seen.add(key) |
| 66 | + |
| 67 | + s = quadrant[0] * quadrant[1] * quadrant[2] * quadrant[3] |
| 68 | + # if any(q <= 10 for q in nines): |
| 69 | + if rows[40] > 30: |
| 70 | + for yy in range(Y): |
| 71 | + print(end=str(yy)) |
| 72 | + for xx in range(X): |
| 73 | + print(end="#" if (xx, yy) in counts else " ") |
| 74 | + # print(end=str(counts.get((xx, yy), " "))) |
| 75 | + print() |
| 76 | + |
| 77 | + print(quadrant) |
| 78 | + print(i) |
| 79 | + print() |
| 80 | + # time.sleep(0.1) |
| 81 | + |
| 82 | + # print(quadrant) |
| 83 | + |
| 84 | +# print(sorted(seen, reverse=True)) |
| 85 | + |
| 86 | +print(quadrant) |
| 87 | + |
| 88 | +print(s1, s2, sep="\n") |
0 commit comments