結果

問題 No.342 一番ワロタww
ユーザー バカらっくバカらっく
提出日時 2018-06-11 15:20:31
言語 Swift
(5.10.0)
結果
AC  
実行時間 16 ms / 5,000 ms
コード長 1,140 bytes
コンパイル時間 1,283 ms
コンパイル使用メモリ 115,180 KB
実行使用メモリ 7,936 KB
最終ジャッジ日時 2023-08-20 10:47:34
合計ジャッジ時間 2,505 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
7,312 KB
testcase_01 AC 16 ms
7,920 KB
testcase_02 AC 3 ms
7,820 KB
testcase_03 AC 4 ms
7,904 KB
testcase_04 AC 3 ms
7,872 KB
testcase_05 AC 3 ms
7,816 KB
testcase_06 AC 3 ms
7,748 KB
testcase_07 AC 3 ms
7,748 KB
testcase_08 AC 4 ms
7,936 KB
testcase_09 AC 3 ms
7,712 KB
testcase_10 AC 4 ms
7,840 KB
testcase_11 AC 3 ms
7,780 KB
testcase_12 AC 3 ms
7,888 KB
testcase_13 AC 4 ms
7,904 KB
testcase_14 AC 3 ms
7,304 KB
testcase_15 AC 3 ms
7,184 KB
testcase_16 AC 4 ms
7,808 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

class Proc {
    public func doProc() {
        let text = readLine()!
        let inpt = text.map{ $0 }

        var pos = 0

        var ans = [Int:[String]]()
        for i in 0..<inpt.count {
            if i < pos {
                continue
            }
            if inpt[i] == "w" {
                var nextStart = inpt.count
                var cnt = 0
                for j in i..<inpt.count {
                    if inpt[j] != "w" {
                        nextStart = j
                        break
                    } else {
                        cnt += 1
                    }
                }

                if i == 0 {
                    pos = nextStart
                    continue
                }

                let word = String(text.prefix(i).suffix(i-pos))
                if ans[cnt] == nil {
                    ans[cnt] = [String]()
                }
                pos = nextStart
                ans[cnt]!.append(word)
            }
        }

        if let maxIdx = ans.keys.max() {
            ans[maxIdx]!.forEach {
                print($0)
            }
        }
    }
}

Proc().doProc()
0