結果

問題 No.1292 パタパタ三角形
ユーザー c-yanc-yan
提出日時 2020-11-26 00:10:23
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 253 ms / 2,000 ms
コード長 602 bytes
コンパイル時間 92 ms
コンパイル使用メモリ 11,004 KB
実行使用メモリ 41,560 KB
最終ジャッジ日時 2023-10-01 02:03:24
合計ジャッジ時間 2,963 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,828 KB
testcase_01 AC 15 ms
7,844 KB
testcase_02 AC 16 ms
7,812 KB
testcase_03 AC 15 ms
7,908 KB
testcase_04 AC 16 ms
7,828 KB
testcase_05 AC 16 ms
7,964 KB
testcase_06 AC 16 ms
7,792 KB
testcase_07 AC 172 ms
13,916 KB
testcase_08 AC 167 ms
14,060 KB
testcase_09 AC 253 ms
39,696 KB
testcase_10 AC 245 ms
39,120 KB
testcase_11 AC 241 ms
39,640 KB
testcase_12 AC 243 ms
41,516 KB
testcase_13 AC 238 ms
41,560 KB
testcase_14 AC 125 ms
8,356 KB
testcase_15 AC 137 ms
8,436 KB
testcase_16 AC 138 ms
8,360 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

S = input()

x, y = 0, 0
t = {(0, 0)}

s0 = [(-1, 0), (0, -1), (1, 0), (-1, 0), (0, 1), (1, 0)]
s1 = [(-1, 0), (0, 1), (1, 0), (-1, 0), (0, -1), (1, 0)]

for ch in S:
    if ch == 'a':
        if y % 2 == 0:
            dx, dy = s0[x % 6]
        else:
            dx, dy = s1[x % 6]
    elif ch == 'b':
        if y % 2 == 0:
            dx, dy = s0[(x + 4) % 6]
        else:
            dx, dy = s1[(x + 4) % 6]
    elif ch == 'c':
        if y % 2 == 0:
            dx, dy = s0[(x + 2) % 6]
        else:
            dx, dy = s1[(x + 2) % 6]
    x += dx
    y += dy
    t.add((x, y))
print(len(t))
0