Submission #9013015


Source Code Expand

Copy
import itertools
import random

# 有限体上の射影平面
# p = 13として、150本の直線と150個の点を選ぶ
# だいたい 1/13 が条件を満たすので、1700個くらいある

p = 13
N = 150

def projective_coordinate(p):
    for a,b in itertools.product(range(p),range(p)):
        yield (a,b,1)
    for a in range(p):
        yield (a,1,0)
    yield (1,0,0)

P2 = list(projective_coordinate(p))

while True:
    random.shuffle(P2)
    Ls = P2[:N]
    random.shuffle(P2)
    Ps = P2[:N]
    grid = [['.'] * N for _ in range(N)]
    cnt = 0
    for (i,(a,b,c)),(j,(x,y,z)) in itertools.product(enumerate(Ls), enumerate(Ps)):
        f = a * x + b * y + c * z
        if f % p == 0:
            grid[i][j] = 'O'
            cnt += 1
    if cnt >= 1700:
        break

print(N)
print('\n'.join(''.join(row) for row in grid))

Submission Info

Submission Time
Task D - ほんとうのたたかい
User maspy
Language Python (3.4.3)
Score 100
Code Size 877 Byte
Status AC
Exec Time 46 ms
Memory 4464 KB

Judge Result

Set Name All
Score / Max Score 100 / 100
Status
AC × 1
Set Name Test Cases
All test.txt
Case Name Status Exec Time Memory
test.txt AC 46 ms 4464 KB