結果

問題 No.805 UMG
ユーザー maspy
提出日時 2020-01-16 13:27:44
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 536 ms / 2,000 ms
コード長 408 bytes
コンパイル時間 139 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 44,516 KB
最終ジャッジ日時 2024-11-18 13:57:02
合計ジャッジ時間 17,331 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N = int(readline())
S = np.frombuffer(read(),'S1')[:N]

M = (S == b'M')
U = (S == b'U')
G = (S == b'G')

answer = 0
for i in np.where(M)[0]:
    L = min(i, N-1-i)
    left = U[:i][::-1][:L]
    right = G[i+1:][:L]
    answer += np.count_nonzero(left&right)

print(answer)
0