結果

問題 No.2419 MMA文字列2
ユーザー xueleixuelei
提出日時 2023-08-12 14:02:25
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,094 bytes
コンパイル時間 1,470 ms
コンパイル使用メモリ 173,916 KB
実行使用メモリ 29,440 KB
最終ジャッジ日時 2024-04-30 04:45:52
合計ジャッジ時間 2,993 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
8,064 KB
testcase_01 AC 3 ms
8,200 KB
testcase_02 AC 4 ms
8,176 KB
testcase_03 AC 3 ms
8,064 KB
testcase_04 AC 3 ms
8,024 KB
testcase_05 AC 3 ms
8,228 KB
testcase_06 AC 3 ms
8,064 KB
testcase_07 AC 6 ms
8,192 KB
testcase_08 AC 3 ms
8,176 KB
testcase_09 AC 6 ms
8,260 KB
testcase_10 AC 3 ms
8,028 KB
testcase_11 AC 2 ms
8,188 KB
testcase_12 AC 12 ms
12,864 KB
testcase_13 AC 4 ms
8,568 KB
testcase_14 AC 20 ms
17,040 KB
testcase_15 AC 13 ms
13,556 KB
testcase_16 AC 23 ms
17,664 KB
testcase_17 AC 6 ms
10,820 KB
testcase_18 AC 22 ms
17,920 KB
testcase_19 AC 22 ms
18,240 KB
testcase_20 AC 7 ms
11,144 KB
testcase_21 AC 6 ms
10,264 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 7 ms
10,496 KB
testcase_27 AC 47 ms
29,440 KB
testcase_28 AC 47 ms
29,440 KB
testcase_29 AC 44 ms
29,312 KB
testcase_30 AC 44 ms
29,388 KB
testcase_31 AC 44 ms
29,400 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define rep(i, a, b) for (int i = (int)(a); (i) < (int)(b); (i)++)
#define rrep(i, a, b) for (int i = (int)(b) - 1; (i) >= (int)(a); (i)--)
#define all(v) v.begin(), v.end()

typedef long long ll;
template <class T> using V = vector<T>;
template <class T> using VV = vector<V<T>>;

V<int> G[200010];
V<bool> used(200010);
int nc = 0;

void f(int k) {
    used[k] = 1;
    nc++;
    rep(i,0,G[k].size()) {
        int to = G[k][i];
        if (used[to]) continue;
        f(to);
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    constexpr char endl = '\n';

    string s;
    cin >> s;
    VV<int> v(26, V<int>(s.size()));
    rep(i,0,s.size()) {
        v[s[i]-'A'][i]++;
        if (i != 0) {
            rep(j,0,26) {
                v[j][i] += v[j][i-1];
            }
        }
    }
    ll ans = 0;
    rep(i,1,s.size()-1) {
        int lft = v[s[i]-'A'][i-1];
        int rt = s.size() - i - 1 - v[s[i]-'A'][s.size()-1] + v[s[i]-'A'][i];
        ans += lft * rt;
    }
    cout << ans << endl;
    return 0;
}
0