-
Notifications
You must be signed in to change notification settings - Fork 0
/
Playlists.kt
39 lines (33 loc) · 1.01 KB
/
Playlists.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
37
38
39
package setsandmaps
import java.io.File
fun main() {
val input = File("input.txt").bufferedReader()
val fileOutput = File("output.txt")
fileOutput.writeText("")
val n = input.readLine().toInt()
input.readLine()
var set = input.readLine().split(' ').toSet()
repeat(n - 1) {
input.readLine()
set = set.intersect(input.readLine().split(' ').toSet())
}
fileOutput.appendText(set.size.toString() + '\n' + set.sorted().joinToString(" "))
}
//import java.io.File
//
//fun main() {
// val input = File("input.txt").bufferedReader()
// val fileOutput = File("output.txt")
// fileOutput.writeText("")
//
// val n = input.readLine().toInt()
// val map = HashMap<String, Int>()
//
// repeat(n) {
// input.readLine()
// input.readLine().split(' ').forEach { map[it] = map.getOrDefault(it, 0) + 1 }
// }
//
// val res = map.filter { (_, value) -> value == n }.keys.sorted()
// fileOutput.appendText(res.size.toString() + '\n' + res.joinToString(" "))
//}