結果

問題 No.805 UMG
ユーザー nebukuro09
提出日時 2019-03-22 21:25:50
言語 D
(dmd 2.109.1)
結果
AC  
実行時間 17 ms / 2,000 ms
コード長 576 bytes
コンパイル時間 675 ms
コンパイル使用メモリ 113,888 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-13 04:23:35
合計ジャッジ時間 1,630 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

immutable long MOD = 10^^9 + 7;

void main() {
    auto N = readln.chomp.to!int;
    auto S = readln.chomp;
    long ans = 0;

    foreach (i; 0..N) {
        if (S[i] != 'M') continue;
        foreach (j; 0..i) {
            int k = 2 * i - j;
            if (k < 0 || k >= N) continue;
            if (S[j] == 'U' && S[k] == 'G') ans += 1;
        }
    }

    ans.writeln;
}
0