-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathD.kt
36 lines (29 loc) · 824 Bytes
/
D.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import java.util.*
fun main() {
val input = System.`in`.bufferedReader()
val output = StringBuilder()
var store = TreeMap<String, Long>()
var (n, m) = input.readLine()!!.split(' ').map { it.toInt() }
repeat(n) {
var s = input.readLine()!!
store[s] = store.getOrDefault(s, 0L) + 1
}
var q = input.readLine()!!.toInt()
repeat(q) {
var ans = 0L
var s = input.readLine()
var uni = TreeSet<String>()
for(ignore in 0..m) {
var gen = ""
for(i in 0..m) {
if(ignore == i) continue
gen += s[i]
}
if(uni.contains(gen)) continue
ans += store.getOrDefault(gen, 0L)
uni.add(gen)
}
output.append("$ans\n")
}
print(output)
}