提出 #54569196


ソースコード 拡げる

import java.io.*
import java.util.*
import kotlin.collections.*
import kotlin.math.*

val INPUT: InputStream = System.`in`
val OUTPUT: PrintStream = System.out

val _reader = INPUT.bufferedReader()

var _tokenizer: StringTokenizer = StringTokenizer("")
fun read(): String {
    while (!_tokenizer.hasMoreTokens()) {
        _tokenizer = StringTokenizer(_reader.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 readInts(n: Int) = List(n) { readInt() }
fun readIntArray(n: Int) = IntArray(n) { readInt() }
fun readDoubles(n: Int) = List(n) { readDouble() }
fun readDoubleArray(n: Int) = DoubleArray(n) { readDouble() }
fun readLongs(n: Int) = List(n) { readLong() }
fun readLongArray(n: Int) = LongArray(n) { readLong() }

val _writer = PrintWriter(OUTPUT, false)
inline fun output(block: PrintWriter.() -> Unit) {
    _writer.apply(block).flush()
}

class MutableIntMap<K> : LinkedHashMap<K, Int>() {
    override operator fun get(key: K): Int = super.get(key) ?: 0

    fun increment(key: K, value: Int = 1) {
        this[key] = this[key] + value
    }

    companion object {
        fun <K> mutableIntMapOf(vararg pairs: Pair<K, Int>) =
            MutableIntMap<K>().apply { putAll(pairs) }
    }
}

typealias Pii = Pair<Int, Int>

fun readPii() = readInt() to readInt()
fun readPiis(n: Int) = List(n) { readPii() }

infix fun Int.hasBit(i: Int): Boolean = this and (1 shl i) > 0
infix fun Int.xorBit(i: Int): Int = this xor (1 shl i)
infix fun Long.hasBit(i: Int): Boolean = this and (1L shl i) > 0
infix fun Long.xorBit(i: Int): Long = this xor (1L shl i)

fun largerStackSize(stackSizeMegaBytes: Int = 100, action: () -> Unit) {
    Thread(null, action, "", 1024L * 1024 * stackSizeMegaBytes).apply {
        start()
        join()
    }
}

// #################################################################################################

fun solve() {
    val n = readInt()
    val m = readInt()
    val s = readStrings(n).map {
        var a = 0
        for (i in 0 until m) if (it[i] == 'o') a = a xorBit i
        a
    }
    val h = 1 shl m
    var f = IntArray(h) { 10 }
    f[0] = 0
    for (a in s) {
        val g = f.clone()
        for (i in 0 until h) {
            g[i or a] = g[i or a].coerceAtMost(f[i] + 1)
        }
        f = g
    }
    println(f[h - 1])
}

fun main() {
//    repeat(readInt()) { solve() }
    solve()
}

提出情報

提出日時
問題 C - Popcorn
ユーザ wangchaohui
言語 Kotlin (Kotlin/JVM 1.8.20)
得点 300
コード長 2617 Byte
結果 AC
実行時間 98 ms
メモリ 39324 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 300 / 300
結果
AC × 3
AC × 28
セット名 テストケース
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 02_handmade_00.txt, 02_handmade_01.txt, 02_handmade_02.txt, 02_handmade_03.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 58 ms 39196 KiB
00_sample_01.txt AC 56 ms 38952 KiB
00_sample_02.txt AC 57 ms 39156 KiB
01_random_00.txt AC 58 ms 39064 KiB
01_random_01.txt AC 98 ms 39132 KiB
01_random_02.txt AC 56 ms 39276 KiB
01_random_03.txt AC 59 ms 39036 KiB
01_random_04.txt AC 59 ms 39112 KiB
01_random_05.txt AC 53 ms 39020 KiB
01_random_06.txt AC 57 ms 39168 KiB
01_random_07.txt AC 57 ms 39040 KiB
01_random_08.txt AC 57 ms 38972 KiB
01_random_09.txt AC 59 ms 39092 KiB
01_random_10.txt AC 57 ms 39248 KiB
01_random_11.txt AC 52 ms 39212 KiB
01_random_12.txt AC 53 ms 39140 KiB
01_random_13.txt AC 54 ms 39116 KiB
01_random_14.txt AC 56 ms 38924 KiB
01_random_15.txt AC 55 ms 39020 KiB
01_random_16.txt AC 58 ms 39184 KiB
01_random_17.txt AC 58 ms 39324 KiB
01_random_18.txt AC 53 ms 39040 KiB
01_random_19.txt AC 57 ms 38968 KiB
01_random_20.txt AC 53 ms 39040 KiB
02_handmade_00.txt AC 59 ms 39100 KiB
02_handmade_01.txt AC 55 ms 38868 KiB
02_handmade_02.txt AC 53 ms 39064 KiB
02_handmade_03.txt AC 54 ms 38960 KiB