結果

問題 No.2419 MMA文字列2
ユーザー RuiRui
提出日時 2023-08-12 13:58:39
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,130 bytes
コンパイル時間 1,532 ms
コンパイル使用メモリ 172,504 KB
実行使用メモリ 30,148 KB
最終ジャッジ日時 2024-04-30 04:38:35
合計ジャッジ時間 3,548 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 13 ms
9,344 KB
testcase_13 AC 3 ms
5,376 KB
testcase_14 AC 24 ms
14,848 KB
testcase_15 AC 14 ms
10,240 KB
testcase_16 AC 24 ms
15,232 KB
testcase_17 AC 9 ms
6,912 KB
testcase_18 AC 27 ms
15,872 KB
testcase_19 AC 26 ms
16,128 KB
testcase_20 AC 8 ms
7,296 KB
testcase_21 AC 6 ms
6,016 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 7 ms
6,528 KB
testcase_27 AC 46 ms
30,080 KB
testcase_28 AC 59 ms
30,024 KB
testcase_29 AC 57 ms
30,148 KB
testcase_30 AC 61 ms
30,080 KB
testcase_31 AC 56 ms
29,948 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;

typedef long long ll;
//typedef modint1000000007 mint;
const int MOD = 1000000007;
#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int inf = 1 << 30;
const ll INF = 1LL << 60;
const int dx[8] = {1, 0, -1, 0, -1, -1, 1, 1};
const int dy[8] = {0, 1, 0, -1, -1, 1, -1, 1};
template <class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

int main(){
    string s;
    cin >> s;

    vector<vector<int>> vec(s.size() + 1, vector<int>(26, 0));
    rep(i, s.size()) vec[i][s[i] - 'A']++;
    rep(i, s.size()) rep(j, 26) vec[i + 1][j] += vec[i][j];

    //後ろの一文字を決める
    ll ans = 0;
    rep(i, 26){
        rep(j, s.size()){
            if(s[j] == 'A' + i){
                rep(k, 26){
                    if(i != k) ans += vec[j][k] * (vec[j][k] - 1);
                }
            }
        }
    }


    cout << ans / 2 << endl;

    return 0;
}
0