結果

問題 No.2419 MMA文字列2
ユーザー 0214sh70214sh7
提出日時 2023-08-12 14:03:09
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 7 ms / 2,000 ms
コード長 1,529 bytes
コンパイル時間 2,179 ms
コンパイル使用メモリ 199,920 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-30 04:49:25
合計ジャッジ時間 3,319 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 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 3 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 4 ms
5,376 KB
testcase_15 AC 3 ms
5,376 KB
testcase_16 AC 4 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 4 ms
5,376 KB
testcase_19 AC 4 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 3 ms
5,376 KB
testcase_22 AC 6 ms
5,376 KB
testcase_23 AC 6 ms
5,376 KB
testcase_24 AC 7 ms
5,376 KB
testcase_25 AC 7 ms
5,376 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 6 ms
5,376 KB
testcase_28 AC 6 ms
5,376 KB
testcase_29 AC 7 ms
5,376 KB
testcase_30 AC 7 ms
5,376 KB
testcase_31 AC 6 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PP;
//#define MOD 1000000007
#define MOD 998244353
#define INF 2305843009213693951
//#define INF 810114514
#define PI 3.141592653589
#define setdouble setprecision
#define REP(i,n) for(ll i=0;i<(n);++i)
#define OREP(i,n) for(ll i=1;i<=(n);++i)
#define RREP(i,n) for(ll i=(n)-1;i>=0;--i)
#define ALL(v) (v).begin(), (v).end()
#define GOODBYE do { cout << "-1" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug true
#define debug2 false


int main(void){
    //cin.tie(nullptr);
    //ios::sync_with_stdio(false);
    
    string S;
    cin >> S;
    ll N = S.size();

    //0~iまでで文字jはいくつあるか
    ll dp1[26] = {};

    //0~iまでで重複する文字jはいくつあるか
    ll dp2[26] = {};

    ll dp2sum = 0;

    ll Ans = 0;

    REP(i,N){
        if(i==0){
            dp1[S[i]-'A']++;
            continue;
        }

        /*ll tmp1[26], tmp2[26];

        REP(j,26){tmp1[j]+=dp1[j];}
        REP(j,26){tmp2[j]+=dp2[j];}*/

        int c = S[i]-'A';

        dp2[c]+=dp1[c];
        dp2sum+=dp1[c];
        dp1[c]++;

        Ans += (dp2sum-dp2[c]);

        /*REP(j,26){cout << (char)('A'+j) << " ";}cout << endl;
        REP(j,26){cout << dp1[j] << " ";}cout << endl;
        REP(j,26){cout << dp2[j] << " ";}cout << endl;
        cout << Ans << endl << endl;*/

        /*swap(dp1,tmp1);
        swap(dp2,tmp2);*/

    }

    cout << Ans << endl;

    
    return 0;
}
0