結果

問題 No.805 UMG
ユーザー Maboy
提出日時 2021-06-24 19:33:18
言語 Swift
(6.0.3)
結果
TLE  
実行時間 -
コード長 535 bytes
コンパイル時間 11,129 ms
コンパイル使用メモリ 127,640 KB
実行使用メモリ 18,048 KB
最終ジャッジ日時 2024-11-18 14:12:52
合計ジャッジ時間 27,835 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 19 TLE * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

let N = Int(readLine()!)!
let S = String(readLine()!)
let l = (N-3)/2
var c = 0
for i in 0...l{   //文字間隔
    for j in 0...(N-1)-(i+1)*2{
        //print(j,j+(i+1),j+(i+1)*2)
        var t = [S.index(S.startIndex, offsetBy: j)]
        if S[t[0]] != "U"{continue}
        t += [S.index(S.startIndex, offsetBy: j+(i+1))]
        if S[t[1]] != "M"{continue}
        t += [S.index(S.startIndex, offsetBy: j+(i+1)*2)]
        let T = t.map{String(S[$0])}
        if T.joined() == "UMG"{
            c += 1
        }
    }
}
print(c)
0