結果
問題 | No.701 ひとりしりとり |
ユーザー | Pump0129 |
提出日時 | 2018-11-28 17:25:42 |
言語 | Java21 (openjdk 21) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,306 bytes |
コンパイル時間 | 2,684 ms |
コンパイル使用メモリ | 81,252 KB |
実行使用メモリ | 71,188 KB |
最終ジャッジ日時 | 2023-09-09 05:49:49 |
合計ジャッジ時間 | 8,826 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 126 ms
62,836 KB |
testcase_01 | AC | 125 ms
55,620 KB |
testcase_02 | AC | 125 ms
56,020 KB |
testcase_03 | AC | 128 ms
55,920 KB |
testcase_04 | AC | 132 ms
57,672 KB |
testcase_05 | AC | 131 ms
55,712 KB |
testcase_06 | AC | 130 ms
55,592 KB |
testcase_07 | AC | 131 ms
55,308 KB |
testcase_08 | AC | 138 ms
55,600 KB |
testcase_09 | AC | 220 ms
55,944 KB |
testcase_10 | AC | 697 ms
61,684 KB |
testcase_11 | TLE | - |
ソースコード
package net.ipipip0129.yukicoder.no701; import java.util.ArrayList; import java.util.List; import java.util.Random; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int num_cnt = scan.nextInt(); String prev_str = "aaa"; List<String> stringList = new ArrayList<>(); for (int i = 0; i < num_cnt - 1; i++) { while (true) { String moji = createRandomString(prev_str.charAt(0), prev_str.charAt(prev_str.length() - 1)); if (!stringList.contains(moji)) { stringList.add(moji); prev_str = moji; System.out.println(moji); break; } } } System.out.println(createRandomString(prev_str.charAt(0), 'n')); } public static String createRandomString(Character begin, Character end) { Random rand = new Random(); StringBuilder sb = new StringBuilder(); sb.append(begin); for (int i = 0; i < 18; i++) { sb.append(Character.toChars(rand.nextInt(26) + 97 )); } sb.append(end); return sb.toString(); } }