結果

問題 No.2419 MMA文字列2
ユーザー tentententen
提出日時 2024-05-02 15:42:05
言語 Java21
(openjdk 21)
結果
AC  
実行時間 136 ms / 2,000 ms
コード長 1,513 bytes
コンパイル時間 4,664 ms
コンパイル使用メモリ 77,756 KB
実行使用メモリ 40,076 KB
最終ジャッジ日時 2024-05-02 15:42:16
合計ジャッジ時間 8,537 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
36,872 KB
testcase_01 AC 45 ms
37,076 KB
testcase_02 AC 45 ms
37,068 KB
testcase_03 AC 44 ms
37,048 KB
testcase_04 AC 44 ms
36,796 KB
testcase_05 AC 43 ms
36,560 KB
testcase_06 AC 47 ms
36,896 KB
testcase_07 AC 46 ms
36,964 KB
testcase_08 AC 45 ms
36,884 KB
testcase_09 AC 47 ms
36,644 KB
testcase_10 AC 46 ms
36,848 KB
testcase_11 AC 44 ms
36,964 KB
testcase_12 AC 66 ms
37,788 KB
testcase_13 AC 49 ms
37,076 KB
testcase_14 AC 83 ms
38,860 KB
testcase_15 AC 67 ms
38,040 KB
testcase_16 AC 74 ms
38,628 KB
testcase_17 AC 72 ms
38,112 KB
testcase_18 AC 89 ms
38,820 KB
testcase_19 AC 95 ms
39,080 KB
testcase_20 AC 67 ms
37,940 KB
testcase_21 AC 71 ms
37,736 KB
testcase_22 AC 136 ms
39,684 KB
testcase_23 AC 125 ms
39,376 KB
testcase_24 AC 114 ms
39,724 KB
testcase_25 AC 123 ms
39,744 KB
testcase_26 AC 75 ms
37,844 KB
testcase_27 AC 115 ms
39,728 KB
testcase_28 AC 109 ms
40,000 KB
testcase_29 AC 116 ms
39,616 KB
testcase_30 AC 127 ms
40,076 KB
testcase_31 AC 111 ms
39,612 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        long[] singles = new long[26];
        long[] doubles = new long[26];
        long ans = 0;
        for (char c : sc.next().toCharArray()) {
            int idx = c - 'A';
            for (int i = 0; i < 26; i++) {
                if (i != idx) {
                    ans += doubles[i];
                }
            }
            doubles[idx] += singles[idx];
            singles[idx]++;
        }
        System.out.println(ans);
    }
}
class Scanner {
    BufferedReader br;
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
        } catch (Exception e) {
            
        }
    }
    
    public int nextInt() {
        return Integer.parseInt(next());
    }
    
    public long nextLong() {
        return Long.parseLong(next());
    }
    
    public double nextDouble() {
        return Double.parseDouble(next());
    }
    
    public String next() {
        try {
            while (!st.hasMoreTokens()) {
                st = new StringTokenizer(br.readLine());
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            return st.nextToken();
        }
    }
    
}
0