結果

問題 No.805 UMG
ユーザー maspymaspy
提出日時 2020-01-16 13:27:44
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 593 ms / 2,000 ms
コード長 408 bytes
コンパイル時間 219 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 44,256 KB
最終ジャッジ日時 2024-04-29 11:02:54
合計ジャッジ時間 18,319 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 550 ms
43,812 KB
testcase_01 AC 552 ms
43,872 KB
testcase_02 AC 566 ms
43,484 KB
testcase_03 AC 555 ms
43,864 KB
testcase_04 AC 558 ms
43,496 KB
testcase_05 AC 533 ms
43,620 KB
testcase_06 AC 548 ms
43,480 KB
testcase_07 AC 545 ms
43,488 KB
testcase_08 AC 536 ms
43,488 KB
testcase_09 AC 554 ms
43,744 KB
testcase_10 AC 550 ms
43,488 KB
testcase_11 AC 529 ms
43,620 KB
testcase_12 AC 527 ms
43,872 KB
testcase_13 AC 529 ms
43,364 KB
testcase_14 AC 522 ms
43,868 KB
testcase_15 AC 534 ms
43,744 KB
testcase_16 AC 538 ms
43,864 KB
testcase_17 AC 529 ms
44,256 KB
testcase_18 AC 546 ms
44,256 KB
testcase_19 AC 548 ms
43,744 KB
testcase_20 AC 543 ms
44,128 KB
testcase_21 AC 533 ms
44,008 KB
testcase_22 AC 566 ms
43,744 KB
testcase_23 AC 593 ms
43,880 KB
testcase_24 AC 579 ms
43,740 KB
testcase_25 AC 554 ms
43,880 KB
testcase_26 AC 559 ms
43,740 KB
testcase_27 AC 548 ms
44,000 KB
権限があれば一括ダウンロードができます

ソースコード

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