結果

問題 No.805 UMG
ユーザー 👑 H20H20
提出日時 2021-06-16 09:21:54
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 153 ms / 2,000 ms
コード長 320 bytes
コンパイル時間 414 ms
コンパイル使用メモリ 87,116 KB
実行使用メモリ 78,260 KB
最終ジャッジ日時 2023-08-11 19:59:34
合計ジャッジ時間 4,470 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
71,628 KB
testcase_01 AC 93 ms
76,608 KB
testcase_02 AC 92 ms
71,540 KB
testcase_03 AC 89 ms
71,500 KB
testcase_04 AC 89 ms
71,684 KB
testcase_05 AC 87 ms
71,620 KB
testcase_06 AC 88 ms
71,668 KB
testcase_07 AC 87 ms
71,756 KB
testcase_08 AC 93 ms
76,752 KB
testcase_09 AC 88 ms
71,684 KB
testcase_10 AC 88 ms
71,612 KB
testcase_11 AC 87 ms
71,732 KB
testcase_12 AC 91 ms
71,488 KB
testcase_13 AC 93 ms
76,792 KB
testcase_14 AC 86 ms
71,700 KB
testcase_15 AC 101 ms
77,448 KB
testcase_16 AC 100 ms
77,588 KB
testcase_17 AC 101 ms
77,488 KB
testcase_18 AC 103 ms
77,624 KB
testcase_19 AC 98 ms
76,972 KB
testcase_20 AC 103 ms
77,564 KB
testcase_21 AC 98 ms
77,660 KB
testcase_22 AC 99 ms
77,384 KB
testcase_23 AC 153 ms
78,048 KB
testcase_24 AC 143 ms
78,260 KB
testcase_25 AC 149 ms
78,044 KB
testcase_26 AC 142 ms
78,228 KB
testcase_27 AC 149 ms
78,056 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