結果

問題 No.2419 MMA文字列2
ユーザー bluemeganebluemegane
提出日時 2023-08-19 12:55:44
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 103 ms / 2,000 ms
コード長 783 bytes
コンパイル時間 2,563 ms
コンパイル使用メモリ 62,992 KB
実行使用メモリ 63,392 KB
最終ジャッジ日時 2023-08-19 12:55:50
合計ジャッジ時間 5,833 ms
ジャッジサーバーID
(参考情報)
judge11 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
22,524 KB
testcase_01 AC 44 ms
20,536 KB
testcase_02 AC 44 ms
20,476 KB
testcase_03 AC 44 ms
22,540 KB
testcase_04 AC 44 ms
22,536 KB
testcase_05 AC 44 ms
20,540 KB
testcase_06 AC 44 ms
20,496 KB
testcase_07 AC 44 ms
20,520 KB
testcase_08 AC 45 ms
22,472 KB
testcase_09 AC 44 ms
22,468 KB
testcase_10 AC 51 ms
20,472 KB
testcase_11 AC 44 ms
20,520 KB
testcase_12 AC 56 ms
29,152 KB
testcase_13 AC 51 ms
23,332 KB
testcase_14 AC 69 ms
35,580 KB
testcase_15 AC 58 ms
30,856 KB
testcase_16 AC 70 ms
38,504 KB
testcase_17 AC 52 ms
25,476 KB
testcase_18 AC 69 ms
37,348 KB
testcase_19 AC 69 ms
39,916 KB
testcase_20 AC 53 ms
28,148 KB
testcase_21 AC 51 ms
26,348 KB
testcase_22 AC 91 ms
63,292 KB
testcase_23 AC 93 ms
63,324 KB
testcase_24 AC 103 ms
63,264 KB
testcase_25 AC 94 ms
63,392 KB
testcase_26 AC 51 ms
24,868 KB
testcase_27 AC 90 ms
63,292 KB
testcase_28 AC 96 ms
61,300 KB
testcase_29 AC 100 ms
63,280 KB
testcase_30 AC 96 ms
59,284 KB
testcase_31 AC 99 ms
61,228 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using System;

public class Hello
{
    static void Main()
    {
        var s = Console.ReadLine().Trim();
        getAns(s);
    }
    static void getAns(string s)
    {
        var n = s.Length;
        var a = new long[26, n];
        for (int i = 0; i < 26; i++)
        {
            if (s[0] - 'A' == i) a[i, 0] = 1;
            for (int j = 1; j < n; j++)
            {
                a[i, j] = a[i, j - 1];
                if (s[j] - 'A' == i) a[i, j]++;
            }
        }
        var ans = 0L;
        for (int i = 1; i < n - 1; i++)
        {
            var t = s[i] - 'A';
            if (a[t, i - 1] < 1) continue;
            var ww = n - 1 - i - (a[t, n - 1] - a[t, i]);
            ans += ww * (a[t, i - 1]);
        }
        Console.WriteLine(ans);
    }
}
0