Submission #2497240
Source Code Expand
Copy
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.SortedSet; import java.util.StringTokenizer; import java.util.TreeSet; public class Main { String s; int k; public static void main(String args[]) { new Main().run(); } void run() { FastReader sc = new FastReader(); s = sc.next(); k = sc.nextInt(); solve(); } void solve() { SortedSet<String> set = new TreeSet<>(); for (int i = 0; i < s.length(); i++) { for (int j = i + 1; j <= s.length(); j++) { set.add(s.substring(i, j)); } } int count = 1; for (String str : set) { if (count == k) { System.out.println(str); break; } count++; } } static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine() { String str = ""; try { str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } } }
Submission Info
Submission Time | |
---|---|
Task | C - K-th Substring |
User | ynish |
Language | Java8 (OpenJDK 1.8.0) |
Score | 200 |
Code Size | 2126 Byte |
Status | TLE |
Exec Time | 2113 ms |
Memory | 892248 KB |
Judge Result
Set Name | Sample | Subtask | All | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 200 / 200 | 0 / 100 | ||||||||
Status |
|
|
|
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 | 78 ms | 23380 KB |
0_001.txt | AC | 75 ms | 21332 KB |
0_002.txt | AC | 72 ms | 19284 KB |
1_003.txt | AC | 74 ms | 18388 KB |
1_004.txt | AC | 73 ms | 18132 KB |
1_005.txt | AC | 91 ms | 20948 KB |
1_006.txt | AC | 81 ms | 21460 KB |
1_007.txt | AC | 75 ms | 19156 KB |
1_008.txt | AC | 91 ms | 21460 KB |
1_009.txt | AC | 88 ms | 20052 KB |
1_010.txt | AC | 80 ms | 21588 KB |
2_011.txt | TLE | 2110 ms | 296704 KB |
2_012.txt | TLE | 2110 ms | 298408 KB |
2_013.txt | TLE | 2113 ms | 770336 KB |
2_014.txt | TLE | 2113 ms | 769112 KB |
2_015.txt | TLE | 2108 ms | 770596 KB |
2_016.txt | TLE | 2112 ms | 809432 KB |
2_017.txt | TLE | 2112 ms | 892248 KB |
2_018.txt | TLE | 2112 ms | 863112 KB |