Submission #2501788


Source Code Expand

#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define LOWER(a,x) lower_bound(ALL(a), x) - a.begin() - 1;
#define COUNT(a,x)  upper_bound(ALL(a), x) - lower_bound(ALL(a), x);
#define MCOUNT(a,x,y) upper_bound(ALL(a), y) - lower_bound(ALL(a), x);
#define INF 111111111111111111
#define MOD 1000000007
#define pb push_back
#define F first
#define S second
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef map<ll, ll> MAP;
ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, tmp = 0, ma = 0, mi = 0;
string s;
bool flag, ok;
ll dx[4] = { 1,-1,0,0 }, dy[4] = { 0,0,1,-1 };
ll ddx[8] = { 1,-1,0,0,1,1,-1,-1 }, ddy[8] = { 0,0,1,-1,1,-1,1,-1 };
#pragma endregion
#define MAX 111111


int main(void) {
  map<string, ll> mp;
  vector<string> vs;
  string ss;
  cin >> s;
  cin >> n;

  char c = 'a';

  while (1) {
	flag = false;
	FOR(i, 0, s.length()) {
	  if (c == s[i])flag = true;
	}

	if (!flag) {
	  c++;
	  continue;
	}

	FOR(i, 1, s.length() + 1) {
	  ok = false;
	  FOR(j, 0, s.length() - i + 1) {
		ss = "";
		if (s[j] == c) {
		  FOR(k, j, j + i) {
			ss += s[k];
		  }
		  if (mp[ss] == 0) {
			vs.pb(ss);
			mp[ss]++;
			cnt++;
			ok = true;
		  }
		}
	  }
	  if (!ok) {
		break;
	  }
	}
	if (cnt >= n) break;
	c++;
  }

  sort(ALL(vs));
  cout << vs[n - 1] << endl;

  return 0;
}

Submission Info

Submission Time
Task C - K-th Substring
User hide1214
Language C++14 (GCC 5.4.1)
Score 200
Code Size 1778 Byte
Status TLE
Exec Time 2135 ms
Memory 415856 KB

Judge Result

Set Name Sample Subtask All
Score / Max Score 0 / 0 200 / 200 0 / 100
Status
AC × 3
AC × 11
AC × 11
TLE × 8
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 2 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 2103 ms 384 KB
2_012.txt TLE 2103 ms 896 KB
2_013.txt TLE 2124 ms 337008 KB
2_014.txt TLE 2125 ms 345580 KB
2_015.txt TLE 2135 ms 415856 KB
2_016.txt TLE 2125 ms 344556 KB
2_017.txt TLE 2124 ms 343404 KB
2_018.txt TLE 2125 ms 344428 KB