Submission #2501750


Source Code Expand

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef double LF;

#define clr(x, y) memset(x, y, sizeof(x))

const int MAXN = 5e3 + 15;

char ch[MAXN], s[MAXN]; int K, n, m, cnt = 0;

bool find(){
//	for(int i = 1; i <= m; i ++) cout << s[i]; puts(""	);
//	cout<<m<<endl;
	for(int i = 1; i <= n; i ++){
		bool flag = 1;
		for(int j = 1; j <= m; j ++) if(ch[i + j - 1] != s[j]){flag = 0; break;}
		if(flag) return 1;
	}
	return 0;
}

void work(){
	scanf("%s %d", ch + 1, &K); n = strlen(ch + 1);
	for(int i = 0; i <= 26; i ++)
		for(int j = -1; j <= 26; j ++)
			for(int k = -1; k <= (j == -1 ? -1 : 26); k ++)
				for(int l = -1; l <= (k == -1 ? -1 : 26); l ++)
					for(int r = -1; r <= (l == -1 ? -1 : 26); r ++){
						s[1] = char(97 + i), s[2] = char(97 + j), s[3] = char(97 + k), s[4] = char(97 + l), s[5] = char(97 + r);
						if(j == -1) m = 1; else if(k == -1) m = 2; else if(l == -1) m = 3; else if(r == -1) m = 4; else m = 5;
						if(find()){cnt ++;}
						if(cnt == K){for(int gg = 1; gg <= m; gg ++) cout << s[gg]; puts(""); return ;}
					}
}

int main(){
	work();
	return 0;
}

Submission Info

Submission Time
Task C - K-th Substring
User stevenzheng2002
Language C++14 (GCC 5.4.1)
Score 200
Code Size 1156 Byte
Status TLE
Exec Time 2103 ms
Memory 764 KB

Compile Error

./Main.cpp: In function ‘void work()’:
./Main.cpp:26:28: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%s %d", ch + 1, &K); n = strlen(ch + 1);
                            ^

Judge Result

Set Name Sample Subtask All
Score / Max Score 0 / 0 200 / 200 0 / 100
Status
AC × 3
AC × 11
AC × 18
TLE × 1
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 11 ms 764 KB
0_001.txt AC 11 ms 256 KB
0_002.txt AC 50 ms 256 KB
1_003.txt AC 64 ms 256 KB
1_004.txt AC 8 ms 256 KB
1_005.txt AC 774 ms 256 KB
1_006.txt AC 38 ms 256 KB
1_007.txt AC 4 ms 256 KB
1_008.txt AC 24 ms 256 KB
1_009.txt AC 58 ms 256 KB
1_010.txt AC 55 ms 256 KB
2_011.txt TLE 2103 ms 256 KB
2_012.txt AC 1815 ms 256 KB
2_013.txt AC 44 ms 256 KB
2_014.txt AC 2 ms 256 KB
2_015.txt AC 11 ms 256 KB
2_016.txt AC 5 ms 256 KB
2_017.txt AC 17 ms 256 KB
2_018.txt AC 2 ms 256 KB