Submission #2499468


Source Code Expand

Copy
#include <cstdio>
#include <set>
#include <string>
using namespace std;

int cmp(const void* a, const void* b)
{
	return strcmp((char*)a, (char*)b);
}
int main()
{
	char s[5001];
	int k;
	scanf("%s %d", s, &k);

	int len = strlen(s), idx = 0;
	set<string> lex;
	for (int i = 0; i < len; ++i)
	{
		string tmp;
		for (int j = 0; i + j < len && j < 5; ++j)
		{
			tmp.push_back(s[i + j]);
			lex.insert(tmp);
		}
	}

	auto it = lex.begin();
	for (; --k; ++it);
	puts(it->c_str());

	return 0;
}

Submission Info

Submission Time
Task C - K-th Substring
User YunGoon
Language C++14 (GCC 5.4.1)
Score 0
Code Size 523 Byte
Status CE

Compile Error

./Main.cpp: In function ‘int cmp(const void*, const void*)’:
./Main.cpp:8:34: error: ‘strcmp’ was not declared in this scope
  return strcmp((char*)a, (char*)b);
                                  ^
./Main.cpp: In function ‘int main()’:
./Main.cpp:16:20: error: ‘strlen’ was not declared in this scope
  int len = strlen(s), idx = 0;
                    ^
./Main.cpp:14:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%s %d", s, &k);
                       ^