結果

問題 No.2268 NGワード回避
ユーザー kusagame12kusagame12
提出日時 2023-11-07 21:02:07
言語 Java21
(openjdk 21)
結果
AC  
実行時間 333 ms / 2,000 ms
コード長 844 bytes
コンパイル時間 2,261 ms
コンパイル使用メモリ 75,260 KB
実行使用メモリ 60,956 KB
最終ジャッジ日時 2023-11-07 21:02:24
合計ジャッジ時間 15,892 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
57,268 KB
testcase_01 AC 114 ms
56,272 KB
testcase_02 AC 123 ms
57,520 KB
testcase_03 AC 116 ms
56,296 KB
testcase_04 AC 112 ms
56,248 KB
testcase_05 AC 121 ms
57,316 KB
testcase_06 AC 122 ms
57,476 KB
testcase_07 AC 122 ms
57,448 KB
testcase_08 AC 155 ms
57,740 KB
testcase_09 AC 153 ms
57,612 KB
testcase_10 AC 156 ms
57,888 KB
testcase_11 AC 153 ms
57,872 KB
testcase_12 AC 155 ms
57,732 KB
testcase_13 AC 157 ms
57,780 KB
testcase_14 AC 154 ms
57,904 KB
testcase_15 AC 154 ms
57,764 KB
testcase_16 AC 151 ms
57,732 KB
testcase_17 AC 150 ms
55,780 KB
testcase_18 AC 159 ms
57,696 KB
testcase_19 AC 157 ms
57,828 KB
testcase_20 AC 158 ms
57,752 KB
testcase_21 AC 157 ms
57,880 KB
testcase_22 AC 156 ms
57,756 KB
testcase_23 AC 161 ms
57,840 KB
testcase_24 AC 157 ms
57,872 KB
testcase_25 AC 156 ms
57,752 KB
testcase_26 AC 157 ms
57,752 KB
testcase_27 AC 155 ms
57,660 KB
testcase_28 AC 155 ms
57,788 KB
testcase_29 AC 158 ms
57,884 KB
testcase_30 AC 156 ms
57,792 KB
testcase_31 AC 156 ms
57,656 KB
testcase_32 AC 153 ms
57,756 KB
testcase_33 AC 154 ms
57,820 KB
testcase_34 AC 157 ms
57,452 KB
testcase_35 AC 159 ms
57,784 KB
testcase_36 AC 159 ms
57,800 KB
testcase_37 AC 153 ms
57,876 KB
testcase_38 AC 153 ms
57,744 KB
testcase_39 AC 153 ms
57,732 KB
testcase_40 AC 158 ms
57,824 KB
testcase_41 AC 156 ms
57,876 KB
testcase_42 AC 155 ms
57,740 KB
testcase_43 AC 153 ms
57,752 KB
testcase_44 AC 161 ms
57,660 KB
testcase_45 AC 157 ms
57,852 KB
testcase_46 AC 154 ms
57,828 KB
testcase_47 AC 333 ms
60,756 KB
testcase_48 AC 318 ms
60,956 KB
testcase_49 AC 324 ms
60,864 KB
testcase_50 AC 325 ms
60,876 KB
testcase_51 AC 329 ms
60,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        List<String> ngWords = new ArrayList<>();
        while(sc.hasNext()){
            ngWords.add(sc.next());
        }

        sc.close();
        
        char a = 'a';
        char b = 'b';
        StringBuilder sb = new StringBuilder();
        for(int i = 0 ; i < n ; i++){
            sb.append(a);
        }
        
        for(int i = 0 ; i < n ; i++){
            String str = sb.toString();
            if(!ngWords.contains(str)){
                System.out.println(str);
                return;
            }
            sb.setCharAt(i , b);
        }
        
        System.out.println(sb.toString());
        
    }
    
}
0