結果

問題 No.1292 パタパタ三角形
ユーザー marroncastlemarroncastle
提出日時 2020-11-20 22:07:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 165 ms / 2,000 ms
コード長 436 bytes
コンパイル時間 318 ms
コンパイル使用メモリ 87,116 KB
実行使用メモリ 122,744 KB
最終ジャッジ日時 2023-09-30 19:20:11
合計ジャッジ時間 3,325 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 95 ms
71,280 KB
testcase_01 AC 94 ms
70,932 KB
testcase_02 AC 93 ms
71,176 KB
testcase_03 AC 93 ms
70,884 KB
testcase_04 AC 91 ms
71,080 KB
testcase_05 AC 95 ms
71,272 KB
testcase_06 AC 93 ms
70,880 KB
testcase_07 AC 136 ms
85,300 KB
testcase_08 AC 129 ms
84,136 KB
testcase_09 AC 165 ms
122,660 KB
testcase_10 AC 163 ms
122,684 KB
testcase_11 AC 163 ms
122,660 KB
testcase_12 AC 157 ms
122,480 KB
testcase_13 AC 162 ms
122,744 KB
testcase_14 AC 116 ms
76,780 KB
testcase_15 AC 114 ms
76,312 KB
testcase_16 AC 115 ms
76,508 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

S = input()
lis = [[0]*3 for _ in range(6)]
lis[0] = [(0,-1), (-1,0), (1,0)]
for i in range(1,6):
  for j in range(3):
    a = lis[i-1][(j-1)%3][0]
    b = -lis[i-1][(j-1)%3][1]
    lis[i][j] = (a,b)
from collections import defaultdict
d = defaultdict(lambda: 0)
x = y = 0
d[(x,y)] = 1
for s in S:
  if y%2==1:
    p = (x+3)%6
  else:
    p = x%6
  a,b = lis[p][ord(s)-ord('a')]
  x += a
  y += b
  d[(x,y)] = 1
ans = len(d)
print(ans)
0