結果

問題 No.1292 パタパタ三角形
ユーザー ygd.ygd.
提出日時 2020-11-20 22:08:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 170 ms / 2,000 ms
コード長 1,045 bytes
コンパイル時間 399 ms
コンパイル使用メモリ 87,188 KB
実行使用メモリ 109,584 KB
最終ジャッジ日時 2023-09-30 19:20:30
合計ジャッジ時間 3,170 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,392 KB
testcase_01 AC 75 ms
71,372 KB
testcase_02 AC 75 ms
71,516 KB
testcase_03 AC 73 ms
71,456 KB
testcase_04 AC 75 ms
71,324 KB
testcase_05 AC 73 ms
71,640 KB
testcase_06 AC 75 ms
71,456 KB
testcase_07 AC 145 ms
82,820 KB
testcase_08 AC 145 ms
82,208 KB
testcase_09 AC 170 ms
109,532 KB
testcase_10 AC 169 ms
109,304 KB
testcase_11 AC 167 ms
109,240 KB
testcase_12 AC 165 ms
109,216 KB
testcase_13 AC 168 ms
109,584 KB
testcase_14 AC 116 ms
77,216 KB
testcase_15 AC 116 ms
77,096 KB
testcase_16 AC 118 ms
77,184 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

S = str(input())
N = len(S)
B = [[(2,0),(0,0)],[(0,1),(1,0)],[(1,0),(0,1)],[(0,0),(0,2)],[(-1,0),(0,1)],[(0,-1),(1,0)],\
[(-2,0),(0,0)],[(0,-1),(-1,0)],[(-1,0),(0,-1)],[(0,0),(0,-2)],[(1,0),(0,-1)],[(0,1),(-1,0)]]
#print(B)
L = set()
now = ((0,0),(0,0))
L.add(now)
a = 30; b = 150; c = 270
for i in range(1,N+1):
  if S[i-1] == "a":
    move = a//30
    a = (a+180)%360
    if i%2 == 0:
      b = (a+120)%360
      c = (a+240)%360
    else:
      c = (a+120)%360
      b = (a+240)%360      
  elif S[i-1] == "b":
    move = b//30
    b = (b+180)%360
    if i%2 == 0:
      a = (b+240)%360
      c = (b+120)%360
    else:
      c = (b+240)%360
      a = (b+120)%360      
  else:
    move = c//30
    c = (c+180)%360
    if i%2 == 0:
      a = (c+120)%360
      b = (c+240)%360
    else:
      b = (c+120)%360
      a = (c+240)%360
  #print(move,B[move])
  nxt = ((now[0][0]+B[move][0][0],now[0][1]+B[move][0][1]),(now[1][0]+B[move][1][0],now[1][1]+B[move][1][1]))
  L.add(nxt)
  now = nxt
  #print(nxt,a,b,c)
ans = len(L)
print(ans)
  
         
0