結果

問題 No.1994 Confusing Name
ユーザー tentententen
提出日時 2023-08-08 14:41:25
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,171 ms / 2,000 ms
コード長 2,295 bytes
コンパイル時間 2,555 ms
コンパイル使用メモリ 87,936 KB
実行使用メモリ 54,036 KB
最終ジャッジ日時 2024-04-26 07:23:32
合計ジャッジ時間 19,755 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
37,352 KB
testcase_01 AC 65 ms
37,788 KB
testcase_02 AC 68 ms
37,808 KB
testcase_03 AC 61 ms
37,444 KB
testcase_04 AC 62 ms
38,064 KB
testcase_05 AC 128 ms
43,064 KB
testcase_06 AC 137 ms
43,404 KB
testcase_07 AC 109 ms
40,648 KB
testcase_08 AC 130 ms
43,496 KB
testcase_09 AC 152 ms
44,180 KB
testcase_10 AC 136 ms
43,512 KB
testcase_11 AC 129 ms
42,716 KB
testcase_12 AC 922 ms
53,488 KB
testcase_13 AC 1,171 ms
52,652 KB
testcase_14 AC 957 ms
54,036 KB
testcase_15 AC 812 ms
51,268 KB
testcase_16 AC 709 ms
50,656 KB
testcase_17 AC 795 ms
51,796 KB
testcase_18 AC 966 ms
52,256 KB
testcase_19 AC 982 ms
53,704 KB
testcase_20 AC 988 ms
53,336 KB
testcase_21 AC 392 ms
46,280 KB
testcase_22 AC 293 ms
45,752 KB
testcase_23 AC 927 ms
53,964 KB
testcase_24 AC 948 ms
53,932 KB
testcase_25 AC 670 ms
50,472 KB
testcase_26 AC 404 ms
46,480 KB
testcase_27 AC 858 ms
51,296 KB
testcase_28 AC 666 ms
50,580 KB
testcase_29 AC 228 ms
45,148 KB
testcase_30 AC 725 ms
51,816 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        String[] names = new String[n];
        HashSet<String> exists = new HashSet<>();
        for (int i = 0; i < n; i++) {
            names[i] = sc.next();
            exists.add(names[i]);
        }
        int[] ans = new int[n];
        for (int i = 0; i < n; i++) {
            char[] inputs = names[i].toCharArray();
            for (int j = 0; j < inputs.length; j++) {
                inputs[j] = (char)((inputs[j] - 'a' + 1) % 26 + 'a');
                for (int k = 0; k < 25; k++) {
                    if (exists.contains(new String(inputs))) {
                        ans[i]++;
                    }
                    inputs[j] = (char)((inputs[j] - 'a' + 1) % 26 + 'a');
                }
            }
        }
        System.out.println(String.join("\n", Arrays.stream(ans).mapToObj(String::valueOf).toArray(String[]::new)));
    }
} 
class Utilities {
    static String arrayToLineString(Object[] arr) {
        return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n"));
    }
    
    static String arrayToLineString(int[] arr) {
        return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new));
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public int[] nextIntArray() throws Exception {
        return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0