Submission #2498831
Source Code Expand
#include <bits/stdc++.h> using namespace std; int bst[6]; int jr[6]; char str[5005]; set<int> st; int n, m; int main(){ scanf("%s", str); scanf("%d",&m); jr[0] = 1; for(int i=1;i<=5;i++){ jr[i] = jr[i-1] * 27; } n = (int)strlen(str); for(int i=0;i<5;i++) bst[i] = jr[5] + 1; for(int i=0;i<n;i++){ int val = 0; for(int j=0;j<5;j++){ if(i+j >= n) break; val += jr[4-j] * ((str[i+j] - 'a') + 1); //printf("%d\n", val); for(int k=0;k<5;k++){ if(bst[k] > val){ for(int l=3;l>=k;l--){ bst[l+1] = bst[l]; } bst[k] = val; break; }else if(bst[k] == val) break; } } } //for(int i=0;i<5;i++) printf("%d\n", bst[i]); for(int i=4;i>=0;i--){ int target = (bst[m-1]%jr[i+1]) / jr[i]; if(target != 0) printf("%c", target+'a'-1); } printf("\n"); }
Submission Info
Submission Time | |
---|---|
Task | C - K-th Substring |
User | jihoon |
Language | C++14 (GCC 5.4.1) |
Score | 300 |
Code Size | 1069 Byte |
Status | AC |
Exec Time | 1 ms |
Memory | 256 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:10:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%s", str); ^ ./Main.cpp:11:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d",&m); ^
Judge Result
Set Name | Sample | Subtask | All | ||||||
---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 200 / 200 | 100 / 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 | 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 | 1 ms | 256 KB |
2_012.txt | AC | 1 ms | 256 KB |
2_013.txt | AC | 1 ms | 256 KB |
2_014.txt | AC | 1 ms | 256 KB |
2_015.txt | AC | 1 ms | 256 KB |
2_016.txt | AC | 1 ms | 256 KB |
2_017.txt | AC | 1 ms | 256 KB |
2_018.txt | AC | 1 ms | 256 KB |