結果
| 問題 |
No.455 冬の大三角
|
| コンテスト | |
| ユーザー |
shiccocsan
|
| 提出日時 | 2016-12-12 21:51:16 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 31 ms / 2,000 ms |
| コード長 | 1,216 bytes |
| コンパイル時間 | 340 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 11,392 KB |
| 最終ジャッジ日時 | 2024-06-29 21:38:12 |
| 合計ジャッジ時間 | 3,840 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 54 |
ソースコード
import random
m = 10 ** (-10)
def eq(a, b):
return a - m <= b <= a + m
def p(stars, b):
x1 = stars[0][0] - b[0]
x2 = stars[1][0] - b[0]
y1 = stars[0][1] - b[1]
y2 = stars[1][1] - b[1]
if (x1 == 0 and x2 == 0) or (y1 == 0 and y2 == 0):
return True
if x2 == 0:
x1, x2 = x2, x1
y1, y2 = y2, y1
if y2 == 0:
return False
return eq(x1 / x2, y1 / y2)
def run():
H, W = list(map(int, input().split()))
stars = []
for i in range(H):
s = input()
if len(stars) < 2:
k = 0
for j in range(2):
f = s.find('*', k)
if f >= 0:
stars.append((i, f))
k = f + 1
else:
break
while 1:
star3 = (random.randint(0, H - 1), random.randint(0, W - 1))
if star3 not in stars and not p(stars, star3):
stars.append(star3)
break
for i in range(H):
row = '-' * W
for a in [s for s in stars if s[0] == i]:
row = row[:a[1]] + '*' + (row[a[1] + 1:] if a[1] < W - 1 else '')
print(row)
run()
# print(p(((0, 1), (1, 4)), (3, 10)))
shiccocsan