-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsolution.kt
More file actions
31 lines (30 loc) · 873 Bytes
/
Copy pathsolution.kt
File metadata and controls
31 lines (30 loc) · 873 Bytes
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
import java.io.*
fun main(args: Array<out String>) {
var s = 0
BufferedReader(InputStreamReader(System.`in`)).lines().iterator().asSequence().take(readLine()!!.toInt()).mapNotNull { line ->
val split = line.split(" ")
val command = split[0]
val arg = if (split.size > 1) 1 shl (split[1].toInt() - 1) else 0
when (command) {
"add" -> {
s = s or arg
}
"remove" -> {
s = s and arg.inv()
}
"check" -> {
return@mapNotNull if(arg and s != 0) "1" else "0"
}
"toggle" -> {
s = s xor arg
}
"all" -> {
s = 0xFFFFF
}
"empty" -> {
s = 0
}
}
null
}.joinToString("\n").let(::println)
}