提出 #67940940


ソースコード 拡げる

import java.util.*;
import java.io.*;

public class Main {
    static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
    static Reader in = new Reader();
    static int[][] dirs = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};
    static int[][] dirs_8 = {{0, -1}, {0, 1}, {1, 0}, {-1, 0}, {1, 1}, {1, -1}, {-1, 1}, {-1, -1}};
    static long LNF = Long.MAX_VALUE / 2;
    static int INF = Integer.MAX_VALUE / 2;
    static int[] dx = {-1, 1, -1, 1};
    static int[] dy = {-1, -1, 1, 1};
    static final long MOD = 998244353;

    public static void main(String[] args) {
//        int t = in.nextInt();
        int t = 1;
        while (t-- > 0) {
            solve();
        }
        out.close();
    }

    static void solve() {
        n = in.nextInt();
        k = in.nextInt();
        long x = in.nextLong();

        s = new String[n];
        for (int i = 0; i < n; i++) s[i] = in.next();

        all("", 0);

        Collections.sort(res);
        out.println(res.get((int)x - 1));
    }

    static List<String> res = new ArrayList<>();
    static String[] s;
    static int n, k;

    static void all(String curr, int d) {
        if (d == k) {
            res.add(curr);
            return;
        }
        for (int i = 0; i < n; i++) {
            all(curr + s[i], d + 1);
        }
    }


    public static boolean isPrime(long n) {
        if (n <= 1) return false;
        if (n <= 3) return true;
        if (n % 2 == 0 || n % 3 == 0) return false;

        for (long i = 5; i * i <= n; i += 6) {
            if (n % i == 0 || n % (i + 2) == 0)
                return false;
        }
        return true;
    }


    static class Pair {
        long first;
        long second;

        Pair(long a, long b) {
            first = a;
            second = b;
        }
    }

    public static boolean isSorted(int[] arr) {
        int n = arr.length;
        for (int i = 1; i < n; i++) {
            if (arr[i - 1] > arr[i])
                return false;
        }
        return true;
    }

    public static int[] removeDuplicates(int[] sortedArray) {
        if (sortedArray.length == 0) return new int[0];

        int uniqueCount = 1;

        // First, count how many unique elements there are
        for (int i = 1; i < sortedArray.length; i++) {
            if (sortedArray[i] != sortedArray[i - 1]) {
                uniqueCount++;
            }
        }

        // Create a new array for the unique elements
        int[] result = new int[uniqueCount];
        result[0] = sortedArray[0];
        int index = 1;

        for (int i = 1; i < sortedArray.length; i++) {
            if (sortedArray[i] != sortedArray[i - 1]) {
                result[index++] = sortedArray[i];
            }
        }

        return result;
    }


    // <------------------------------------------------------------------------------------->
    static long sqrt(long x) {
        long y = (long) Math.sqrt(x);
        if (y * y <= x) {
            return y;
        }
        return y - 1;
    }

    static void setOut(String path) {
        try {
            out = new PrintWriter(new FileOutputStream(path));
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        }
    }

    static long lowbit(long x) {
        return x & -x;
    }

    static void sort(int[] arr) {
        //because Arrays.sort() uses quicksort which is dumb
        //Collections.sort() uses merge sort
        ArrayList<Integer> ls = new ArrayList<Integer>();
        for (int x : arr)
            ls.add(x);
        Collections.sort(ls);
        for (int i = 0; i < arr.length; i++)
            arr[i] = ls.get(i);
    }

    static void sort(long[] arr) {
        //because Arrays.sort() uses quicksort which is dumb
        //Collections.sort() uses merge sort
        ArrayList<Long> ls = new ArrayList<>();
        for (long x : arr)
            ls.add(x);
        Collections.sort(ls);
        for (int i = 0; i < arr.length; i++)
            arr[i] = ls.get(i);
    }

    static void reverseSort(int[] arr) {
        //because Arrays.sort() uses quicksort which is dumb
        //Collections.sort() uses merge sort
        ArrayList<Integer> ls = new ArrayList<Integer>();
        for (int x : arr)
            ls.add(x);
        ls.sort(Collections.reverseOrder());
        for (int i = 0; i < arr.length; i++)
            arr[i] = ls.get(i);
    }

    static void swap(char[] s, int i, int j) {
        char t = s[i];
        s[i] = s[j];
        s[j] = t;
    }

    static <T> void swap(T[] nums, int i, int j) {
        T t = nums[i];
        nums[i] = nums[j];
        nums[j] = t;
    }

    static void swap(int[] nums, int i, int j) {
        int temp = nums[i];
        nums[i] = nums[j];
        nums[j] = temp;
    }

    static long pow(long x, long n) {
        if (n <= 0) {
            return 1;
        }
        long res = 1;
        for (; n > 0; n >>= 1, x = x * x) {
            if ((n & 1) == 1) {
                res = res * x;
            }
        }
        return res;
    }

    static long pow(long x, long n, long mod) {
        if (n <= 0) {
            return 1;
        }
        x %= mod;
        long res = 1;
        for (; n > 0; n >>= 1, x = x * x % mod) {
            if ((n & 1) == 1) {
                res = res * x % mod;
            }
        }
        return res;
    }

    static long gcd(long a, long b) {
        return b == 0 ? a : gcd(b, a % b);
    }

    static int gcd(int a, int b) {
        return b == 0 ? a : gcd(b, a % b);
    }

    static int getBit(int s, int i) {
        return (s >> i) & 1;
    }

    static int getBit(long s, int i) {
        return (int) (s >> i) & 1;
    }

    static int setBit(int s, int i, int b) {
        if (getBit(s, i) == 1) s ^= 1 << i;
        return s | b << i;
    }

    static long max(long... nums) {
        long res = Long.MIN_VALUE;
        for (long x : nums) {
            res = Math.max(res, x);
        }
        return res;
    }

    static int max(int... nums) {
        int res = Integer.MIN_VALUE;
        for (int x : nums) {
            res = Math.max(res, x);
        }
        return res;
    }

    static long min(long... nums) {
        long res = Long.MAX_VALUE;
        for (long x : nums) {
            res = Math.min(res, x);
        }
        return res;
    }

    static int min(int... nums) {
        int res = Integer.MAX_VALUE;
        for (int x : nums) {
            res = Math.min(res, x);
        }
        return res;
    }

    static class UnionFind {
        int[] parent;
        int size;
        int[] counts;

        UnionFind(int n) {
            size = n;
            parent = new int[n];
            Arrays.setAll(parent, i -> i);
            counts = new int[n];
            Arrays.fill(counts, 1);
        }

        int find(int x) {
            while (parent[x] != x) {
                x = parent[x] = parent[parent[x]];
            }
            return x;
        }

        boolean union(int x, int y) {
            x = find(parent[x]);
            y = find(parent[y]);
            if (x == y) {
                return false;
            }
            parent[x] = y;
            counts[y] += counts[x];
            size--;
            return true;
        }

        int getSize() {
            return size;
        }

        int getCount(int x) {
            return counts[find(x)];
        }

        boolean connect(int x, int y) {
            return find(parent[x]) == find(parent[y]);
        }

        void set(int x, int fa) {
            parent[x] = fa;
        }
    }

    static List<Integer>[] build_graph(int n, int m) {
        List<Integer>[] g = new List[n + 1];
        Arrays.setAll(g, e -> new ArrayList<>());
        for (int i = 0; i < m; i++) {
            int x = in.nextInt(), y = in.nextInt();
            g[x].add(y);
            g[y].add(x);
        }
        return g;
    }

    static <T> void print(List<T> list) {
        for (T x : list) {
            out.print(x + " ");
        }
        out.println();
    }


    static class Reader {
        private BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        private StringTokenizer st;

        void set(String path) {
            try {
                br = new BufferedReader(new FileReader(path));
            } catch (Exception ignored) {
            }
        }

        boolean hasNext() {
            try {
                while (st == null || !st.hasMoreElements()) {
                    st = new StringTokenizer(br.readLine());
                }
            } catch (Exception e) {
                return false;
            }
            return true;
        }

        String next() {
            try {
                while (st == null || !st.hasMoreElements()) {
                    st = new StringTokenizer(br.readLine());
                }
            } catch (Exception ignored) {
            }
            return st.nextToken();
        }

        String nextLine() {
            String s = "";
            try {
                s = br.readLine();
            } catch (Exception ignored) {
            }
            return s;
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        int[] nextIntArray(int n, int start) {
            int[] arr = new int[n + start];
            for (int i = start; i < arr.length; i++) {
                arr[i] = nextInt();
            }
            return arr;
        }

        int[] nextIntArray(int n) {
            return nextIntArray(n, 0);
        }

        int[][] nextIntArray2(int n, int m) {
            int[][] grid = new int[n][];
            Arrays.setAll(grid, i -> grid[i] = nextIntArray(m));
            return grid;
        }

        long[] nextLongArray(int n, int start) {
            long[] arr = new long[n + start];
            for (int i = start; i < arr.length; i++) {
                arr[i] = nextLong();
            }
            return arr;
        }

        long[] nextLongArray(int n) {
            return nextLongArray(n, 0);
        }

        long[][] nextLongArray2(int n, int m) {
            long[][] grid = new long[n][];
            Arrays.setAll(grid, i -> grid[i] = nextLongArray(m));
            return grid;
        }

        char[][] nextCharArray(int n) {
            char[][] grid = new char[n][];
            Arrays.setAll(grid, i -> grid[i] = nextLine().toCharArray());
            return grid;
        }

        String[] nextStrArray(int n) {
            String[] arr = new String[n];
            Arrays.setAll(arr, i -> arr[i] = nextLine());
            return arr;
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        double[] nextDoubleArray(int n, int start) {
            double[] arr = new double[n + start];
            for (int i = start; i < arr.length; i++) {
                arr[i] = nextDouble();
            }
            return arr;
        }

        double[] nextDoubleArray(int n) {
            return nextDoubleArray(n, 0);
        }
    }

}

提出情報

提出日時
問題 C - Concat (X-th)
ユーザ ash432
言語 Java (OpenJDK 17)
得点 300
コード長 11614 Byte
結果 AC
実行時間 160 ms
メモリ 50360 KiB

コンパイルエラー

Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 300 / 300
結果
AC × 2
AC × 27
セット名 テストケース
Sample sample_01.txt, sample_02.txt
All hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_06.txt, hand_07.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, sample_01.txt, sample_02.txt
ケース名 結果 実行時間 メモリ
hand_01.txt AC 60 ms 36004 KiB
hand_02.txt AC 160 ms 48064 KiB
hand_03.txt AC 54 ms 36080 KiB
hand_04.txt AC 151 ms 47104 KiB
hand_06.txt AC 46 ms 35248 KiB
hand_07.txt AC 41 ms 35212 KiB
random_01.txt AC 122 ms 47340 KiB
random_02.txt AC 121 ms 44460 KiB
random_03.txt AC 51 ms 35516 KiB
random_04.txt AC 44 ms 35344 KiB
random_05.txt AC 122 ms 47436 KiB
random_06.txt AC 43 ms 35180 KiB
random_07.txt AC 44 ms 35344 KiB
random_08.txt AC 55 ms 36408 KiB
random_09.txt AC 152 ms 48156 KiB
random_10.txt AC 81 ms 38452 KiB
random_11.txt AC 146 ms 47184 KiB
random_12.txt AC 100 ms 40584 KiB
random_13.txt AC 148 ms 48068 KiB
random_14.txt AC 44 ms 35256 KiB
random_15.txt AC 43 ms 35060 KiB
random_16.txt AC 49 ms 35940 KiB
random_17.txt AC 133 ms 50360 KiB
random_18.txt AC 92 ms 49696 KiB
random_19.txt AC 45 ms 35260 KiB
sample_01.txt AC 43 ms 35144 KiB
sample_02.txt AC 55 ms 36076 KiB