Submission #2501753


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
// typedef __int128_t Int;
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  string s;
  cin >> s;
  int K;
  cin >> K;
  string t(s);
  sort(all(t));
  t.erase(unique(all(t)), t.end());
  set<string> v;
  for (char c = 'a'; c <= 'z'; c++) {
    if (v.size() >= K) {
      break;
    }
    rep(i, 0, s.size()) {
      if (s[i] == c) {
        int j = i;
        string tmp;
        while (j < s.size()) {
          tmp.push_back(s[j++]);
          v.insert(tmp);
        }
      }
    }
  }
  auto it = v.begin();
  loop(K - 1) it = next(it);
  cout << *it << endl;

  return 0;
}

Submission Info

Submission Time
Task C - K-th Substring
User norma
Language C++14 (GCC 5.4.1)
Score 200
Code Size 1459 Byte
Status TLE
Exec Time 2105 ms
Memory 1450368 KB

Judge Result

Set Name Sample Subtask All
Score / Max Score 0 / 0 200 / 200 0 / 100
Status
AC × 3
AC × 11
AC × 13
TLE × 2
MLE × 4
Set Name Test Cases
Sample 0_000.txt, 0_001.txt, 0_002.txt
Subtask 0_000.txt, 0_001.txt, 0_002.txt, 1_003.txt, 1_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt
All 0_000.txt, 0_001.txt, 0_002.txt, 1_003.txt, 1_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 2_011.txt, 2_012.txt, 2_013.txt, 2_014.txt, 2_015.txt, 2_016.txt, 2_017.txt, 2_018.txt
Case Name Status Exec Time Memory
0_000.txt AC 1 ms 256 KB
0_001.txt AC 1 ms 256 KB
0_002.txt AC 1 ms 256 KB
1_003.txt AC 1 ms 256 KB
1_004.txt AC 1 ms 256 KB
1_005.txt AC 1 ms 256 KB
1_006.txt AC 1 ms 256 KB
1_007.txt AC 1 ms 256 KB
1_008.txt AC 1 ms 256 KB
1_009.txt AC 1 ms 256 KB
1_010.txt AC 1 ms 256 KB
2_011.txt TLE 2104 ms 19712 KB
2_012.txt TLE 2105 ms 25600 KB
2_013.txt AC 1016 ms 948736 KB
2_014.txt MLE 1496 ms 1450368 KB
2_015.txt AC 543 ms 502892 KB
2_016.txt MLE 1308 ms 1254912 KB
2_017.txt MLE 1258 ms 1205760 KB
2_018.txt MLE 1354 ms 1296384 KB