백준 11723 kotlin

윤익·2022년 11월 10일
0

https://www.acmicpc.net/problem/11723

fun main()=with(System.out.bufferedWriter()) {
    val M = readLine()!!.toInt()
    val S = mutableSetOf<String>()
    for(i in 0..M-1) {
        val input = readLine()!!.split(' ')
        when(input[0]) {
            "add" -> S.add(input[1])
            "remove" -> S.remove(input[1])
            "check" -> if(S.contains(input[1])) write("1\n") else write("0\n")
            "toggle" -> if(S.contains(input[1])) S.remove(input[1]) else S.add(input[1])
            "all" -> {
                S.clear() 
                for(j in 1..20) S.add(j.toString())
            }
            "empty" -> S.clear()
        }
    }
    close()
}
profile
https://nickyoon.tistory.com/ 기술 블로그 이전

0개의 댓글