結果

問題 No.1292 パタパタ三角形
ユーザー ygd.ygd.
提出日時 2020-11-20 22:08:39
言語 PyPy3
(7.3.8)
結果
AC  
実行時間 269 ms / 2,000 ms
コード長 1,045 bytes
コンパイル時間 233 ms
使用メモリ 119,476 KB
最終ジャッジ日時 2023-02-23 18:26:37
合計ジャッジ時間 3,829 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 79 ms
75,804 KB
testcase_01 AC 77 ms
75,760 KB
testcase_02 AC 76 ms
75,728 KB
testcase_03 AC 78 ms
75,656 KB
testcase_04 AC 75 ms
75,824 KB
testcase_05 AC 78 ms
75,756 KB
testcase_06 AC 77 ms
75,760 KB
testcase_07 AC 236 ms
89,288 KB
testcase_08 AC 220 ms
89,112 KB
testcase_09 AC 252 ms
113,748 KB
testcase_10 AC 269 ms
119,476 KB
testcase_11 AC 253 ms
110,984 KB
testcase_12 AC 165 ms
114,068 KB
testcase_13 AC 168 ms
113,860 KB
testcase_14 AC 125 ms
81,360 KB
testcase_15 AC 136 ms
81,400 KB
testcase_16 AC 127 ms
81,932 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