結果

問題 No.996 Phnom Penh
ユーザー firiexpfiriexp
提出日時 2020-02-22 00:29:33
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 574 ms / 2,000 ms
コード長 1,642 bytes
コンパイル時間 14,578 ms
コンパイル使用メモリ 447,628 KB
実行使用メモリ 74,820 KB
最終ジャッジ日時 2024-04-17 11:08:53
合計ジャッジ時間 26,851 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 302 ms
52,028 KB
testcase_01 AC 313 ms
52,100 KB
testcase_02 AC 322 ms
52,080 KB
testcase_03 AC 314 ms
52,168 KB
testcase_04 AC 311 ms
52,224 KB
testcase_05 AC 308 ms
52,320 KB
testcase_06 AC 312 ms
51,968 KB
testcase_07 AC 317 ms
52,032 KB
testcase_08 AC 314 ms
52,348 KB
testcase_09 AC 310 ms
52,328 KB
testcase_10 AC 320 ms
52,088 KB
testcase_11 AC 310 ms
52,104 KB
testcase_12 AC 310 ms
52,300 KB
testcase_13 AC 537 ms
72,428 KB
testcase_14 AC 538 ms
72,236 KB
testcase_15 AC 537 ms
72,156 KB
testcase_16 AC 537 ms
72,200 KB
testcase_17 AC 524 ms
72,124 KB
testcase_18 AC 324 ms
52,072 KB
testcase_19 AC 311 ms
52,184 KB
testcase_20 AC 301 ms
51,756 KB
testcase_21 AC 310 ms
51,948 KB
testcase_22 AC 308 ms
52,024 KB
testcase_23 AC 320 ms
52,220 KB
testcase_24 AC 574 ms
74,820 KB
testcase_25 AC 551 ms
73,528 KB
testcase_26 AC 545 ms
71,432 KB
testcase_27 AC 558 ms
72,340 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:31:9: warning: variable 'v' is never used
    var v = 0
        ^
Main.kt:49:10: warning: parameter 'args' is never used
fun main(args: Array<String>) {
         ^

ソースコード

diff #

import java.io.PrintWriter
import java.lang.Math.abs
import java.util.*

@JvmField val INPUT = System.`in`
@JvmField val OUTPUT = System.out
@JvmField val cin = INPUT.bufferedReader()
fun readLine(): String? = cin.readLine()
fun readLn() = cin.readLine()!!
@JvmField var _tokenizer: StringTokenizer = StringTokenizer("")
fun read(): String {
    while (_tokenizer.hasMoreTokens().not()) _tokenizer = StringTokenizer(cin.readLine() ?: return "", " ")
    return _tokenizer.nextToken()
}
fun readInt() = read().toInt()
fun readDouble() = read().toDouble()
fun readLong() = read().toLong()
fun readStrings(n: Int) = List(n) { read() }
fun readLines(n: Int) = List(n) { readLn() }
fun readInts(n: Int) = List(n) { read().toInt() }
fun readIntArray(n: Int) = IntArray(n) { read().toInt() }
fun readDoubles(n: Int) = List(n) { read().toDouble() }
fun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }
fun readLongs(n: Int) = List(n) { read().toLong() }
fun readLongArray(n: Int) = LongArray(n) { read().toLong() }
@JvmField val cout = PrintWriter(OUTPUT, false)

fun solve(){
    var s = read()
    var ans = 0
    var v = 0
    for (i in 1..2){
        for (j in 0 until s.length-4){
            if(s.substring(j, j+5) == "phnom") ans++
        }
        s = s.replace("phnom", "penh")
        if(s.contains("[he]".toRegex())){
            ans++
            s = s.replace("h", "").replace('e', 'h')
        }
    }
    for (c in "phn(om)+".toRegex().findAll(s)) {
        ans += c.value.length - 3
    }
    if(s.contains("[he]".toRegex())) ans++
    cout.println(ans)
}

fun main(args: Array<String>) {
    solve()
    cout.flush()
}
0