Submission #54091645


Source Code Expand

import MutableIntMap.Companion.mutableIntMapOf
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 k = readInt()
    val n2 = 1 shl n
    val ans = BooleanArray(n2) { true }
    repeat(m) {
        val c = readInt()
        val a = readInts(c)
        var a2 = 0
        for (i in a) {
            a2 = a2 xorBit i - 1
        }
        val r = read()[0]
        for (b in ans.indices) if (ans[b]) {
            val real = a2 and b
            if (real.countOneBits() >= k) {
                if (r == 'x') {
                    ans[b] = false
                }
            } else {
                if (r == 'o') {
                    ans[b] = false
                }
            }
        }
    }
    println(ans.count { it })
}

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

Submission Info

Submission Time
Task C - Keys
User wangchaohui
Language Kotlin (Kotlin/JVM 1.8.20)
Score 300
Code Size 2932 Byte
Status AC
Exec Time 120 ms
Memory 41852 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 60
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All sample_01.txt, sample_02.txt, sample_03.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt, test_21.txt, test_22.txt, test_23.txt, test_24.txt, test_25.txt, test_26.txt, test_27.txt, test_28.txt, test_29.txt, test_30.txt, test_31.txt, test_32.txt, test_33.txt, test_34.txt, test_35.txt, test_36.txt, test_37.txt, test_38.txt, test_39.txt, test_40.txt, test_41.txt, test_42.txt, test_43.txt, test_44.txt, test_45.txt, test_46.txt, test_47.txt, test_48.txt, test_49.txt, test_50.txt, test_51.txt, test_52.txt, test_53.txt, test_54.txt, test_55.txt, test_56.txt, test_57.txt
Case Name Status Exec Time Memory
sample_01.txt AC 49 ms 37748 KiB
sample_02.txt AC 49 ms 37600 KiB
sample_03.txt AC 50 ms 37832 KiB
test_01.txt AC 48 ms 37848 KiB
test_02.txt AC 48 ms 37716 KiB
test_03.txt AC 46 ms 37692 KiB
test_04.txt AC 89 ms 41292 KiB
test_05.txt AC 86 ms 40580 KiB
test_06.txt AC 90 ms 40768 KiB
test_07.txt AC 93 ms 40768 KiB
test_08.txt AC 49 ms 37772 KiB
test_09.txt AC 53 ms 37812 KiB
test_10.txt AC 54 ms 37896 KiB
test_11.txt AC 49 ms 37856 KiB
test_12.txt AC 49 ms 37716 KiB
test_13.txt AC 49 ms 37600 KiB
test_14.txt AC 52 ms 37804 KiB
test_15.txt AC 60 ms 38256 KiB
test_16.txt AC 52 ms 37832 KiB
test_17.txt AC 49 ms 37728 KiB
test_18.txt AC 50 ms 37864 KiB
test_19.txt AC 50 ms 37668 KiB
test_20.txt AC 74 ms 39452 KiB
test_21.txt AC 47 ms 37820 KiB
test_22.txt AC 52 ms 37900 KiB
test_23.txt AC 53 ms 37896 KiB
test_24.txt AC 51 ms 37720 KiB
test_25.txt AC 53 ms 37944 KiB
test_26.txt AC 51 ms 37688 KiB
test_27.txt AC 46 ms 37712 KiB
test_28.txt AC 87 ms 41304 KiB
test_29.txt AC 95 ms 40600 KiB
test_30.txt AC 87 ms 41380 KiB
test_31.txt AC 90 ms 41268 KiB
test_32.txt AC 88 ms 40676 KiB
test_33.txt AC 88 ms 41292 KiB
test_34.txt AC 85 ms 40580 KiB
test_35.txt AC 74 ms 39252 KiB
test_36.txt AC 89 ms 40804 KiB
test_37.txt AC 94 ms 40868 KiB
test_38.txt AC 87 ms 40788 KiB
test_39.txt AC 91 ms 40660 KiB
test_40.txt AC 53 ms 37800 KiB
test_41.txt AC 93 ms 41500 KiB
test_42.txt AC 52 ms 38080 KiB
test_43.txt AC 78 ms 40496 KiB
test_44.txt AC 97 ms 41484 KiB
test_45.txt AC 73 ms 39296 KiB
test_46.txt AC 72 ms 39284 KiB
test_47.txt AC 94 ms 40596 KiB
test_48.txt AC 88 ms 40480 KiB
test_49.txt AC 87 ms 41088 KiB
test_50.txt AC 87 ms 40864 KiB
test_51.txt AC 92 ms 40692 KiB
test_52.txt AC 89 ms 40620 KiB
test_53.txt AC 89 ms 40592 KiB
test_54.txt AC 74 ms 39088 KiB
test_55.txt AC 76 ms 39320 KiB
test_56.txt AC 80 ms 39976 KiB
test_57.txt AC 120 ms 41852 KiB