結果

問題 No.2671 NUPC Decompressor
ユーザー tentententen
提出日時 2024-03-19 14:49:30
言語 Java21
(openjdk 21)
結果
AC  
実行時間 100 ms / 2,000 ms
コード長 1,728 bytes
コンパイル時間 2,593 ms
コンパイル使用メモリ 81,092 KB
実行使用メモリ 56,540 KB
最終ジャッジ日時 2024-03-19 14:49:35
合計ジャッジ時間 5,005 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 90 ms
52,920 KB
testcase_01 AC 89 ms
55,000 KB
testcase_02 AC 87 ms
55,016 KB
testcase_03 AC 88 ms
54,880 KB
testcase_04 AC 90 ms
55,024 KB
testcase_05 AC 100 ms
55,128 KB
testcase_06 AC 87 ms
54,892 KB
testcase_07 AC 100 ms
56,288 KB
testcase_08 AC 89 ms
54,884 KB
testcase_09 AC 89 ms
54,904 KB
testcase_10 AC 96 ms
56,540 KB
testcase_11 AC 89 ms
54,904 KB
testcase_12 AC 89 ms
54,880 KB
testcase_13 AC 87 ms
55,008 KB
testcase_14 AC 90 ms
55,128 KB
testcase_15 AC 90 ms
55,024 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;
import java.util.function.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int k = sc.nextInt();
        List<TreeSet<String>> list = new ArrayList<>();
        list.add(new TreeSet<>());
        list.get(0).add("");
        char[] nupc = "NUPC".toCharArray();
        for (int i = 1; i <= 8; i++) {
            TreeSet<String> current = new TreeSet<>();
            for (String s : list.get(i - 1)) {
                if (i % 2 == 1) {
                    current.add(s + nupc[i / 2]);   
                } else {
                    current.add(s);
                    current.add(s + s);
                }
            }
            list.add(current);
        }
        System.out.println(list.get(8).toArray()[k - 1]);
    }
}
class Scanner {
    BufferedReader br;
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
        } catch (Exception e) {
            
        }
    }
    
    public int nextInt() {
        return Integer.parseInt(next());
    }
    
    public long nextLong() {
        return Long.parseLong(next());
    }
    
    public double nextDouble() {
        return Double.parseDouble(next());
    }
    
    public String next() {
        try {
            while (!st.hasMoreTokens()) {
                st = new StringTokenizer(br.readLine());
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            return st.nextToken();
        }
    }
    
}
0