結果
問題 | No.701 ひとりしりとり |
ユーザー | shunjikonishi |
提出日時 | 2018-06-15 23:35:05 |
言語 | JavaScript (node v21.7.1) |
結果 |
AC
|
実行時間 | 1,000 ms / 2,000 ms |
コード長 | 922 bytes |
コンパイル時間 | 40 ms |
コンパイル使用メモリ | 5,248 KB |
実行使用メモリ | 70,928 KB |
最終ジャッジ日時 | 2024-04-21 02:08:41 |
合計ジャッジ時間 | 2,959 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 66 ms
39,424 KB |
testcase_01 | AC | 66 ms
39,040 KB |
testcase_02 | AC | 69 ms
39,168 KB |
testcase_03 | AC | 64 ms
39,296 KB |
testcase_04 | AC | 64 ms
39,040 KB |
testcase_05 | AC | 64 ms
39,040 KB |
testcase_06 | AC | 64 ms
39,296 KB |
testcase_07 | AC | 63 ms
39,296 KB |
testcase_08 | AC | 65 ms
39,424 KB |
testcase_09 | AC | 96 ms
45,308 KB |
testcase_10 | AC | 285 ms
47,720 KB |
testcase_11 | AC | 1,000 ms
70,928 KB |
ソースコード
function randomInt(max) { return Math.floor(Math.random() * max); } const CHARS = "abcdefghijklmopqrstuvwxyz"; function randomChar() { const n = randomInt(25); return CHARS.charAt(n); } function generateWord(firstChar) { const len = randomInt(18) + 2; const result = []; if (firstChar) { result.push(firstChar); } while (result.length < len) { result.push(randomChar()); } return result.join(""); } function Main(input) { var data = input.split("\n") var n = parseInt(data[0]); var map = {}; var ret = []; var firstChar = null; while (ret.length < n) { var s = generateWord(firstChar); if (!map[s]) { map[s] = true; ret.push(s); firstChar = s.charAt(s.length - 1); } } ret[ret.length -1] += "n"; ret.forEach(v => console.log(v)); } // Don't edit this line! Main(require("fs").readFileSync("/dev/stdin", "utf8"));