結果

問題 No.2419 MMA文字列2
ユーザー t98slidert98slider
提出日時 2023-08-12 13:49:51
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 24 ms / 2,000 ms
コード長 647 bytes
コンパイル時間 1,711 ms
コンパイル使用メモリ 169,544 KB
実行使用メモリ 44,248 KB
最終ジャッジ日時 2024-04-30 04:13:58
合計ジャッジ時間 3,108 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 6 ms
12,404 KB
testcase_13 AC 3 ms
5,376 KB
testcase_14 AC 11 ms
20,864 KB
testcase_15 AC 11 ms
14,032 KB
testcase_16 AC 11 ms
21,760 KB
testcase_17 AC 6 ms
8,576 KB
testcase_18 AC 11 ms
22,528 KB
testcase_19 AC 11 ms
23,132 KB
testcase_20 AC 6 ms
9,448 KB
testcase_21 AC 5 ms
7,552 KB
testcase_22 AC 23 ms
44,248 KB
testcase_23 AC 24 ms
44,024 KB
testcase_24 AC 22 ms
44,124 KB
testcase_25 AC 23 ms
44,240 KB
testcase_26 AC 5 ms
8,044 KB
testcase_27 AC 22 ms
44,160 KB
testcase_28 AC 22 ms
44,160 KB
testcase_29 AC 23 ms
44,160 KB
testcase_30 AC 23 ms
44,032 KB
testcase_31 AC 23 ms
44,160 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int n = s.size();
    ll ans = 0;
    vector<array<ll, 26>> cnt(n + 1);
    array<ll, 26> tmp{};
    cnt[0] = tmp;
    for(int i = 0; i < n; i++){
        tmp[s[i] - 'A']++;
        cnt[i + 1] = tmp;
    }
    /*for(int j = 0; j < 26; j++){
        cerr << tmp[j] << " ";
    }
    cerr << '\n';*/
    for(int i = 0; i < n; i++){
        ll l = cnt[i][s[i] - 'A'];
        ll r = cnt[n][s[i] - 'A'] - cnt[i][s[i] - 'A'];
        ans += l * (n - i - r);
    }
    cout << ans << '\n';
}
0