提出 #62850626


ソースコード 拡げる

"""
<方針>
- `A` の位置 `a` を全て考える。
- 間隔 `d` を全て考える。
- `B` の位置は `a+d` で、`C` の位置は `a+2*d` となるので、あとはカウントするだけ。
"""
# 入力
S = input()

# 長さ
N = len(S)

# カウント数
ans = 0
for a in range(N):
  for d in range(N):
    # index out of range 対策
    if(a+2*d<N):
      a = a+0*d
      b = a+1*d
      c = a+2*d
      # A, B, Cが存在するかどうか
      if(
        S[a] == "A" and 
        S[b] == "B" and 
        S[c] == "C"
        ):
          # カウントアップ
          ans += 1

# 出力
print(ans)

提出情報

提出日時
問題 B - A..B..C
ユーザ mattsunkun
言語 Python (PyPy 3.10-v7.3.12)
得点 200
コード長 649 Byte
結果 AC
実行時間 62 ms
メモリ 81308 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 200 / 200
結果
AC × 3
AC × 23
セット名 テストケース
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 02_random2_00.txt, 02_random2_01.txt, 02_random2_02.txt, 02_random2_03.txt, 03_handmade_00.txt, 03_handmade_01.txt, 03_handmade_02.txt, 03_handmade_03.txt, 03_handmade_04.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 56 ms 76484 KiB
00_sample_01.txt AC 57 ms 76312 KiB
00_sample_02.txt AC 56 ms 76380 KiB
01_random_00.txt AC 60 ms 80912 KiB
01_random_01.txt AC 56 ms 76636 KiB
01_random_02.txt AC 56 ms 76376 KiB
01_random_03.txt AC 60 ms 81308 KiB
01_random_04.txt AC 62 ms 81144 KiB
01_random_05.txt AC 60 ms 81024 KiB
01_random_06.txt AC 60 ms 81108 KiB
01_random_07.txt AC 59 ms 81160 KiB
01_random_08.txt AC 61 ms 81052 KiB
01_random_09.txt AC 60 ms 81172 KiB
01_random_10.txt AC 60 ms 81120 KiB
02_random2_00.txt AC 61 ms 80956 KiB
02_random2_01.txt AC 61 ms 81060 KiB
02_random2_02.txt AC 60 ms 81176 KiB
02_random2_03.txt AC 61 ms 80916 KiB
03_handmade_00.txt AC 59 ms 80812 KiB
03_handmade_01.txt AC 60 ms 81240 KiB
03_handmade_02.txt AC 57 ms 76636 KiB
03_handmade_03.txt AC 57 ms 76692 KiB
03_handmade_04.txt AC 57 ms 76544 KiB