Submission #70225674
Source Code Expand
const inputText = await Deno.readTextFile("/dev/stdin");
const input = inputText.trim().split("\n").map(row => row.split(" "));
(() => {
// 処理
const [N, K] = input[0].map(n => +n);
const S = input[1][0];
const count = {};
for (let i = 0; i < N + 1 - K; i++) {
const substr = S.substring(i, i + K);
if (count[substr] == null) count[substr] = 0;
count[substr]++;
}
let max = 0;
Object.entries(count).forEach(([substr, count]) => {
if (max < count) max = count;
});
console.log(max);
console.log(Object.entries(count).map(([substr, count]) => {
if (count === max) return substr;
return null;
}).filter(n => n != null).sort().join(" "));
})();
Submission Info
| Submission Time | |
|---|---|
| Task | B - Most Frequent Substrings |
| User | AXT_AyaKoto |
| Language | JavaScript (Deno 1.35.1) |
| Score | 200 |
| Code Size | 760 Byte |
| Status | AC |
| Exec Time | 68 ms |
| Memory | 44396 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 200 / 200 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00-sample-01.txt, 00-sample-02.txt, 00-sample-03.txt |
| All | 00-sample-01.txt, 00-sample-02.txt, 00-sample-03.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00-sample-01.txt | AC | 67 ms | 43528 KiB |
| 00-sample-02.txt | AC | 68 ms | 43860 KiB |
| 00-sample-03.txt | AC | 68 ms | 43576 KiB |
| 01-01.txt | AC | 67 ms | 43880 KiB |
| 01-02.txt | AC | 65 ms | 43900 KiB |
| 01-03.txt | AC | 64 ms | 43836 KiB |
| 01-04.txt | AC | 62 ms | 44120 KiB |
| 01-05.txt | AC | 66 ms | 43528 KiB |
| 01-06.txt | AC | 61 ms | 44396 KiB |
| 01-07.txt | AC | 65 ms | 43628 KiB |
| 01-08.txt | AC | 66 ms | 43960 KiB |
| 01-09.txt | AC | 62 ms | 43308 KiB |
| 01-10.txt | AC | 66 ms | 43860 KiB |
| 01-11.txt | AC | 65 ms | 43304 KiB |
| 01-12.txt | AC | 66 ms | 43832 KiB |
| 01-13.txt | AC | 66 ms | 43568 KiB |
| 01-14.txt | AC | 66 ms | 43684 KiB |
| 01-15.txt | AC | 64 ms | 43380 KiB |
| 01-16.txt | AC | 61 ms | 44300 KiB |
| 01-17.txt | AC | 60 ms | 44004 KiB |
| 01-18.txt | AC | 61 ms | 44268 KiB |
| 01-19.txt | AC | 66 ms | 43960 KiB |