Submission #67944441


Source Code Expand

#include <bits/stdc++.h>
using namespace std;

void generateSequences(int idx, int k, string current, vector<string>& strings, vector<string>& sequences) {
    if (k == 0) {
        sequences.push_back(current);
        return;
    }
    for (int i = 0; i < strings.size(); ++i) {
        generateSequences(i, k - 1, current + strings[i], strings, sequences);
    }
}

int main() {
    int n, k, x;
    cin >> n >> k >> x;
    vector<string> strings(n);
    for (int i = 0; i < n; ++i) {
        cin >> strings[i];
    }

    vector<string> sequences;
    generateSequences(0, k, "", strings, sequences);

    sort(sequences.begin(), sequences.end());

    cout << sequences[x - 1] << "\n";

    return 0;
}

Submission Info

Submission Time
Task C - Concat (X-th)
User Sarthak_Borse
Language C++ 20 (gcc 12.2)
Score 300
Code Size 736 Byte
Status AC
Exec Time 28 ms
Memory 12644 KiB

Compile Error

Main.cpp: In function ‘void generateSequences(int, int, std::string, std::vector<std::__cxx11::basic_string<char> >&, std::vector<std::__cxx11::basic_string<char> >&)’:
Main.cpp:9:23: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<std::__cxx11::basic_string<char> >::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
    9 |     for (int i = 0; i < strings.size(); ++i) {
      |                     ~~^~~~~~~~~~~~~~~~
Main.cpp:4:28: warning: unused parameter ‘idx’ [-Wunused-parameter]
    4 | void generateSequences(int idx, int k, string current, vector<string>& strings, vector<string>& sequences) {
      |                        ~~~~^~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 2
AC × 27
Set Name Test Cases
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
Case Name Status Exec Time Memory
hand_01.txt AC 2 ms 3672 KiB
hand_02.txt AC 27 ms 10384 KiB
hand_03.txt AC 2 ms 3752 KiB
hand_04.txt AC 24 ms 9032 KiB
hand_06.txt AC 1 ms 3476 KiB
hand_07.txt AC 1 ms 3500 KiB
random_01.txt AC 23 ms 9716 KiB
random_02.txt AC 15 ms 7896 KiB
random_03.txt AC 1 ms 3552 KiB
random_04.txt AC 1 ms 3432 KiB
random_05.txt AC 24 ms 10384 KiB
random_06.txt AC 1 ms 3560 KiB
random_07.txt AC 1 ms 3468 KiB
random_08.txt AC 2 ms 3660 KiB
random_09.txt AC 24 ms 11188 KiB
random_10.txt AC 2 ms 3688 KiB
random_11.txt AC 23 ms 9280 KiB
random_12.txt AC 5 ms 4672 KiB
random_13.txt AC 24 ms 11212 KiB
random_14.txt AC 1 ms 3560 KiB
random_15.txt AC 1 ms 3496 KiB
random_16.txt AC 1 ms 3580 KiB
random_17.txt AC 28 ms 12532 KiB
random_18.txt AC 24 ms 12644 KiB
random_19.txt AC 2 ms 3640 KiB
sample_01.txt AC 2 ms 3624 KiB
sample_02.txt AC 2 ms 3684 KiB