Submission #2504348


Source Code Expand

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

int main() {
  string s;
  cin >> s;
  int k;
  cin >> k;
  int n = (int)s.length();
  for (char c = 'a'; ; c += 1) {
    vi ind;
    rep (i, n) {
      if (s[i] == c) {
        ind.push_back(i);
      }
    }
    int m = (int)ind.size();
    set<string> q;
    FOR (i, 1, 6) {
      rep (j, m) {
        if (ind[j] + i > n) {
          break;
        }
        q.insert(s.substr(ind[j], i));
      }
    }
    if ((int)q.size() < k) {
      k -= (int)q.size();
      continue;
    }
    string ans;
    rep (i, k) {
      ans = *begin(q);
      q.erase(begin(q));
    }
    cout << ans << "\n";
    return 0;
  }
  return 0;
}

Submission Info

Submission Time
Task C - K-th Substring
User tspcx
Language C++14 (Clang 3.8.0)
Score 300
Code Size 1526 Byte
Status AC
Exec Time 4 ms
Memory 256 KB

Judge Result

Set Name Sample Subtask All
Score / Max Score 0 / 0 200 / 200 100 / 100
Status
AC × 3
AC × 11
AC × 19
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 AC 3 ms 256 KB
2_012.txt AC 4 ms 256 KB
2_013.txt AC 2 ms 256 KB
2_014.txt AC 2 ms 256 KB
2_015.txt AC 1 ms 256 KB
2_016.txt AC 2 ms 256 KB
2_017.txt AC 2 ms 256 KB
2_018.txt AC 2 ms 256 KB