結果

問題 No.2671 NUPC Decompressor
ユーザー rururun
提出日時 2024-11-08 14:39:47
言語 Swift
(6.0.3)
結果
AC  
実行時間 11 ms / 2,000 ms
コード長 503 bytes
コンパイル時間 9,141 ms
コンパイル使用メモリ 125,372 KB
実行使用メモリ 9,600 KB
最終ジャッジ日時 2024-11-08 14:39:58
合計ジャッジ時間 10,141 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

let k = Int(readLine()!)!
let arr1 = ["N","U","P","C"]
let dic = ["N":2,"U":4,"P":3,"C":1]
var ansArr = [String]()

func kaito(_ p: Int, _ s: String){
    var S = s
    S += arr1[p]
    if p == 3{
        ansArr.append(S)
        ansArr.append(S+S)
    }else{
        let q = String(S.first!)
        if dic[q]! < dic[arr1[p+1]]!{
            kaito(p+1, S+S)
            kaito(p+1, S)
        }else{
            kaito(p+1, S)
            kaito(p+1, S+S)
        }
    }
}
kaito(0, "")
print(ansArr[k-1])
0