Submission #67987903


Source Code Expand

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

/////////////////// メイン ///////////////////

int main () {
  
  //////////////////// 入力 ////////////////////

  int n, k, x;
  cin >> n >> k >> x;

  vector<string> s(n);
  for (int i=0; i<n; i++) {
    cin >> s.at(i);
  }

  //////////////// 出力変数定義 ////////////////

  string result = "";

  //////////////////// 処理 ////////////////////

  // とりあえず、n^kを計算し、そのサイズのvectorを作っておく
  int limit = 1;
  for (int i=0; i<k; i++) {
    limit *= n;
  }
  vector<string> str(limit,"");

  // bit全探索っぽいことをする
  // iをk桁以下のn進数とみなし、str.at(i)にその数に対応する文字列を作る
  // 例えばn進数で123だった場合、s.at(3)+s.at(2)+s.at(1)を作る
  for (int i=0; i<limit; i++) {

    // iを破壊しないように、値をコピー
    int num = i;
    
    // n進数の下から順に、対応する文字を入れる
    for (int j=0; j<k; j++) {
      str.at(i) += s.at(num%n);
      num /= n;
    }

  }

  // 全部ソートしてx番目が答え
  sort(str.begin(),str.end());
  result = str.at(x-1);

  //////////////////// 出力 ////////////////////

  cout << result << endl;

  //////////////////// 終了 ////////////////////

  return 0;

}

Submission Info

Submission Time
Task C - Concat (X-th)
User wightou
Language C++ 23 (gcc 12.2)
Score 300
Code Size 1380 Byte
Status AC
Exec Time 34 ms
Memory 14300 KiB

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 3636 KiB
hand_02.txt AC 25 ms 11784 KiB
hand_03.txt AC 2 ms 3716 KiB
hand_04.txt AC 28 ms 10004 KiB
hand_06.txt AC 1 ms 3512 KiB
hand_07.txt AC 1 ms 3536 KiB
random_01.txt AC 30 ms 10972 KiB
random_02.txt AC 21 ms 8968 KiB
random_03.txt AC 1 ms 3596 KiB
random_04.txt AC 1 ms 3624 KiB
random_05.txt AC 32 ms 11584 KiB
random_06.txt AC 1 ms 3524 KiB
random_07.txt AC 1 ms 3524 KiB
random_08.txt AC 2 ms 3940 KiB
random_09.txt AC 28 ms 12980 KiB
random_10.txt AC 3 ms 3632 KiB
random_11.txt AC 27 ms 10268 KiB
random_12.txt AC 5 ms 4392 KiB
random_13.txt AC 27 ms 12980 KiB
random_14.txt AC 1 ms 3496 KiB
random_15.txt AC 1 ms 3536 KiB
random_16.txt AC 1 ms 3556 KiB
random_17.txt AC 34 ms 13896 KiB
random_18.txt AC 19 ms 14300 KiB
random_19.txt AC 1 ms 3408 KiB
sample_01.txt AC 1 ms 3536 KiB
sample_02.txt AC 1 ms 3568 KiB