結果
問題 | No.2419 MMA文字列2 |
ユーザー | hiromi_ayase |
提出日時 | 2023-08-12 14:42:37 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 176 ms / 2,000 ms |
コード長 | 2,144 bytes |
コンパイル時間 | 2,422 ms |
コンパイル使用メモリ | 77,976 KB |
実行使用メモリ | 53,656 KB |
最終ジャッジ日時 | 2024-04-30 06:57:12 |
合計ジャッジ時間 | 7,331 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 54 ms
50,632 KB |
testcase_01 | AC | 55 ms
50,244 KB |
testcase_02 | AC | 55 ms
50,488 KB |
testcase_03 | AC | 55 ms
50,440 KB |
testcase_04 | AC | 56 ms
50,744 KB |
testcase_05 | AC | 55 ms
50,496 KB |
testcase_06 | AC | 55 ms
52,740 KB |
testcase_07 | AC | 55 ms
50,588 KB |
testcase_08 | AC | 54 ms
50,568 KB |
testcase_09 | AC | 55 ms
50,592 KB |
testcase_10 | AC | 54 ms
50,728 KB |
testcase_11 | AC | 54 ms
50,724 KB |
testcase_12 | AC | 75 ms
51,492 KB |
testcase_13 | AC | 65 ms
51,388 KB |
testcase_14 | AC | 101 ms
51,884 KB |
testcase_15 | AC | 84 ms
51,952 KB |
testcase_16 | AC | 105 ms
51,996 KB |
testcase_17 | AC | 70 ms
51,544 KB |
testcase_18 | AC | 109 ms
52,004 KB |
testcase_19 | AC | 101 ms
51,816 KB |
testcase_20 | AC | 71 ms
51,364 KB |
testcase_21 | AC | 69 ms
51,412 KB |
testcase_22 | AC | 175 ms
53,496 KB |
testcase_23 | AC | 160 ms
52,520 KB |
testcase_24 | AC | 149 ms
52,676 KB |
testcase_25 | AC | 175 ms
53,412 KB |
testcase_26 | AC | 70 ms
51,472 KB |
testcase_27 | AC | 170 ms
53,472 KB |
testcase_28 | AC | 175 ms
53,376 KB |
testcase_29 | AC | 176 ms
53,648 KB |
testcase_30 | AC | 173 ms
53,656 KB |
testcase_31 | AC | 176 ms
53,376 KB |
ソースコード
import java.util.*; import java.io.*; @SuppressWarnings("unused") public class Main { private static void solve() { var s = ns(); long[] cnt = new long[26]; long ret = 0; for (int i = 0; i < s.length; i ++) { int d = s[i] - 'A'; for (int j = 0; j < 26; j ++) { if (d != j) { ret += cnt[j] * (cnt[j] - 1) / 2; } } cnt[d] ++; } System.out.println(ret); } public static void main(String[] args) { new Thread(null, new Runnable() { @Override public void run() { solve(); out.flush(); } }, "", 64000000).start(); } private static PrintWriter out = new PrintWriter(System.out); private static StringTokenizer tokenizer = null; private static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 32768); public static String next() { while (tokenizer == null || !tokenizer.hasMoreTokens()) { try { tokenizer = new java.util.StringTokenizer(reader.readLine()); } catch (Exception e) { throw new RuntimeException(e); } } return tokenizer.nextToken(); } private static double nd() { return Double.parseDouble(next()); } private static long nl() { return Long.parseLong(next()); } private static int[] na(int n) { int[] a = new int[n]; for (int i = 0; i < n; i++) a[i] = ni(); return a; } private static char[] ns() { return next().toCharArray(); } private static long[] nal(int n) { long[] a = new long[n]; for (int i = 0; i < n; i++) a[i] = nl(); return a; } private static int[][] ntable(int n, int m) { int[][] table = new int[n][m]; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { table[i][j] = ni(); } } return table; } private static int[][] nlist(int n, int m) { int[][] table = new int[m][n]; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { table[j][i] = ni(); } } return table; } private static int ni() { return Integer.parseInt(next()); } }