結果
問題 | No.455 冬の大三角 |
ユーザー | amowwee |
提出日時 | 2016-12-06 21:45:52 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 31 ms / 2,000 ms |
コード長 | 1,307 bytes |
コンパイル時間 | 102 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 11,520 KB |
最終ジャッジ日時 | 2024-06-29 21:16:05 |
合計ジャッジ時間 | 3,318 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 25 ms
10,880 KB |
testcase_01 | AC | 27 ms
10,880 KB |
testcase_02 | AC | 27 ms
10,880 KB |
testcase_03 | AC | 25 ms
11,008 KB |
testcase_04 | AC | 25 ms
10,880 KB |
testcase_05 | AC | 26 ms
10,752 KB |
testcase_06 | AC | 26 ms
10,880 KB |
testcase_07 | AC | 26 ms
10,880 KB |
testcase_08 | AC | 31 ms
11,520 KB |
testcase_09 | AC | 28 ms
11,008 KB |
testcase_10 | AC | 28 ms
10,752 KB |
testcase_11 | AC | 28 ms
11,008 KB |
testcase_12 | AC | 26 ms
10,752 KB |
testcase_13 | AC | 25 ms
10,752 KB |
testcase_14 | AC | 28 ms
10,880 KB |
testcase_15 | AC | 26 ms
10,752 KB |
testcase_16 | AC | 26 ms
10,752 KB |
testcase_17 | AC | 26 ms
10,752 KB |
testcase_18 | AC | 26 ms
10,752 KB |
testcase_19 | AC | 25 ms
10,752 KB |
testcase_20 | AC | 26 ms
10,880 KB |
testcase_21 | AC | 26 ms
11,008 KB |
testcase_22 | AC | 26 ms
10,752 KB |
testcase_23 | AC | 26 ms
11,008 KB |
testcase_24 | AC | 26 ms
10,752 KB |
testcase_25 | AC | 27 ms
10,880 KB |
testcase_26 | AC | 26 ms
10,880 KB |
testcase_27 | AC | 26 ms
10,880 KB |
testcase_28 | AC | 25 ms
10,752 KB |
testcase_29 | AC | 28 ms
11,264 KB |
testcase_30 | AC | 26 ms
11,264 KB |
testcase_31 | AC | 27 ms
11,008 KB |
testcase_32 | AC | 28 ms
10,880 KB |
testcase_33 | AC | 29 ms
11,520 KB |
testcase_34 | AC | 27 ms
10,880 KB |
testcase_35 | AC | 29 ms
11,264 KB |
testcase_36 | AC | 28 ms
11,008 KB |
testcase_37 | AC | 27 ms
10,880 KB |
testcase_38 | AC | 27 ms
10,880 KB |
testcase_39 | AC | 28 ms
11,392 KB |
testcase_40 | AC | 28 ms
11,264 KB |
testcase_41 | AC | 27 ms
11,136 KB |
testcase_42 | AC | 27 ms
11,136 KB |
testcase_43 | AC | 29 ms
11,008 KB |
testcase_44 | AC | 28 ms
10,880 KB |
testcase_45 | AC | 30 ms
11,136 KB |
testcase_46 | AC | 28 ms
11,264 KB |
testcase_47 | AC | 27 ms
11,008 KB |
testcase_48 | AC | 27 ms
11,008 KB |
testcase_49 | AC | 26 ms
10,880 KB |
testcase_50 | AC | 26 ms
10,880 KB |
testcase_51 | AC | 26 ms
11,008 KB |
testcase_52 | AC | 27 ms
10,880 KB |
testcase_53 | AC | 27 ms
11,008 KB |
testcase_54 | AC | 25 ms
10,752 KB |
testcase_55 | AC | 25 ms
11,008 KB |
testcase_56 | AC | 26 ms
10,880 KB |
ソースコード
# coding: utf-8 # Sieve of Eratosthenes def sieve(a,b): if(abs(a)<abs(b)): temp = a a = b b = temp while(b): temp = a a = b b = temp%b return abs(a) H,W = map(int,input().split()) # get 2 stars position starPos = [] for row in range(H): col = [i for i, char in enumerate(input()) if char == "*"] while(col): starPos.append((col.pop(), row)) if(len(starPos) == 2): break # star1 -> star2 vector vec = ( starPos[1][0] - starPos[0][0], starPos[1][1] - starPos[0][1] ) div = sieve(vec[0],vec[1]) vec = ( vec[0] / div, vec[1] / div) # enumerate lattice point on the star1--star2 line lattice = [] p = starPos[0] while(0 <= p[0] and W > p[0] and 0 <= p[1] and H > p[1] ): lattice.append(p) p = (p[0]+vec[0], p[1]+vec[1]) p = starPos[0] while(0 <= p[0] and W > p[0] and 0 <= p[1] and H > p[1] ): lattice.append(p) p = (p[0]-vec[0], p[1]-vec[1]) # get 3rd star position for thirdPos in [(x,y) for y in range(H) for x in range(W)]: if not thirdPos in lattice: starPos.append(thirdPos) break # print result sky = [["-" for w in range(W)] for h in range(H)] for i in range(3): sky[starPos[i][1]][starPos[i][0]] = "*" print("\n".join(["".join(s) for s in sky]), "\n")