結果
| 問題 |
No.455 冬の大三角
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-03-26 15:59:55 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 33 ms / 2,000 ms |
| コード長 | 1,177 bytes |
| コンパイル時間 | 77 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 11,008 KB |
| 最終ジャッジ日時 | 2024-06-30 00:57:44 |
| 合計ジャッジ時間 | 3,852 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 54 |
ソースコード
def read_data():
H, W = map(int, input().split())
Ss = [input().rstrip() for h in range(H)]
return H, W, Ss
def solve(H, W, Ss):
x1, y1, x2, y2 = get_star_pos(H, W, Ss)
x3, y3 = put_star(H, W, x1, y1, x2, y2)
print_stars(H, W, x1, y1, x2, y2, x3, y3)
def get_star_pos(H, W, Ss):
xys = []
for y, S in enumerate(Ss):
for x, c in enumerate(S):
if c == '*':
xys.append(x)
xys.append(y)
return xys
def print_stars(H, W, x1, y1, x2, y2, x3, y3):
star_pos = [(x1, y1), (x2, y2), (x3, y3)]
for h in range(H):
row = []
for w in range(W):
if (w, h) in star_pos:
row.append('*')
else:
row.append('-')
print(''.join(row))
def put_star(H, W, x1, y1, x2, y2):
for x in range(W):
for y in range(H):
if is_valid(x1, y1, x2, y2, x, y):
return x, y
raise RuntimeError("Couldn't find star pos.")
def is_valid(x1, y1, x2, y2, x3, y3):
x1 = x1 - x3
x2 = x2 - x3
y1 = y1 - y3
y2 = y2 - y3
return x1 * y2 != x2 * y1
H, W, Ss = read_data()
solve(H, W, Ss)