結果

問題 No.805 UMG
ユーザー MaboyMaboy
提出日時 2021-06-24 19:33:18
言語 Swift
(5.10.0)
結果
TLE  
実行時間 -
コード長 535 bytes
コンパイル時間 1,346 ms
コンパイル使用メモリ 129,764 KB
実行使用メモリ 14,904 KB
最終ジャッジ日時 2023-08-11 20:00:38
合計ジャッジ時間 15,754 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
14,904 KB
testcase_01 AC 14 ms
7,848 KB
testcase_02 AC 4 ms
7,844 KB
testcase_03 AC 4 ms
7,744 KB
testcase_04 AC 3 ms
7,732 KB
testcase_05 AC 3 ms
7,688 KB
testcase_06 AC 3 ms
7,820 KB
testcase_07 AC 4 ms
7,812 KB
testcase_08 AC 6 ms
7,732 KB
testcase_09 AC 4 ms
7,748 KB
testcase_10 AC 3 ms
7,816 KB
testcase_11 AC 4 ms
7,832 KB
testcase_12 AC 3 ms
7,840 KB
testcase_13 AC 6 ms
7,876 KB
testcase_14 AC 3 ms
7,692 KB
testcase_15 AC 1,446 ms
7,756 KB
testcase_16 AC 1,250 ms
7,828 KB
testcase_17 AC 670 ms
7,740 KB
testcase_18 TLE -
testcase_19 AC 436 ms
7,872 KB
testcase_20 TLE -
testcase_21 AC 910 ms
7,752 KB
testcase_22 AC 1,269 ms
7,884 KB
testcase_23 TLE -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
権限があれば一括ダウンロードができます

ソースコード

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