結果

問題 No.805 UMG
ユーザー 👑 H20H20
提出日時 2021-06-16 09:21:54
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 122 ms / 2,000 ms
コード長 320 bytes
コンパイル時間 183 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 67,456 KB
最終ジャッジ日時 2024-04-29 11:15:03
合計ジャッジ時間 3,048 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 50 ms
53,504 KB
testcase_01 AC 56 ms
58,624 KB
testcase_02 AC 47 ms
53,504 KB
testcase_03 AC 50 ms
53,760 KB
testcase_04 AC 48 ms
53,248 KB
testcase_05 AC 51 ms
53,504 KB
testcase_06 AC 50 ms
53,376 KB
testcase_07 AC 47 ms
53,376 KB
testcase_08 AC 53 ms
58,752 KB
testcase_09 AC 49 ms
53,632 KB
testcase_10 AC 49 ms
53,504 KB
testcase_11 AC 49 ms
53,504 KB
testcase_12 AC 48 ms
53,376 KB
testcase_13 AC 50 ms
59,264 KB
testcase_14 AC 48 ms
53,248 KB
testcase_15 AC 68 ms
62,976 KB
testcase_16 AC 63 ms
62,592 KB
testcase_17 AC 64 ms
62,976 KB
testcase_18 AC 62 ms
63,232 KB
testcase_19 AC 61 ms
61,312 KB
testcase_20 AC 65 ms
63,360 KB
testcase_21 AC 63 ms
62,336 KB
testcase_22 AC 64 ms
62,848 KB
testcase_23 AC 122 ms
67,328 KB
testcase_24 AC 113 ms
67,200 KB
testcase_25 AC 117 ms
67,072 KB
testcase_26 AC 112 ms
67,456 KB
testcase_27 AC 115 ms
66,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import collections
N = int(input())
S= input()
U = []
M = []
G = collections.defaultdict(int)
for i in range(N):
    if S[i]=='U':
        U.append(i)
    elif S[i]=='M':
        M.append(i)
    else:
        G[i]=1

ans = 0
for u in U:
    for m in M:
        if u<m and G[u+(m-u)*2]==1:
            ans+=1
print(ans)

0