complete 1092.kt 23029.kt 26587.kt 30553.kt

This commit is contained in:
2025-07-23 20:33:13 +09:00
parent bff1a8295b
commit 2e957b221e
4 changed files with 158 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
fun main() = with(System.`in`.bufferedReader()) {
val (n, m, q) = this.readLine()!!.split(' ').map { it.toInt() }
val characters = (1..n).map { IntArray(m) }
repeat(n) {
val trait = this.readLine()!!
for (i in 0 until m) {
characters[it][i] = when (trait[i]) {
'Y' -> 2
'N' -> 1
else -> 0
}
}
}
val queries = IntArray(m)
repeat(q) {
val iter = this.readLine()!!.split(' ').iterator()
val index = iter.next().toInt() - 1
queries[index] = when (iter.next().first()) {
'Y' -> 2
'N' -> 1
else -> 0
}
}
val filtered = characters.withIndex().filter { (ind, it) ->
(it zip queries).map {
if (it.second == 0) {
true
} else {
it.first == it.second
}
}.all { it }
}
if (filtered.size == 1) {
println("unique")
println(filtered.first().index + 1)
} else {
println("ambiguous")
println(filtered.size)
}
}