結果

問題 No.2419 MMA文字列2
ユーザー yansi819yansi819
提出日時 2024-04-07 11:58:41
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 64 ms / 2,000 ms
コード長 595 bytes
コンパイル時間 4,604 ms
コンパイル使用メモリ 262,616 KB
実行使用メモリ 44,504 KB
最終ジャッジ日時 2024-04-07 11:58:48
合計ジャッジ時間 5,918 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 1 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 2 ms
6,676 KB
testcase_12 AC 16 ms
12,928 KB
testcase_13 AC 5 ms
6,676 KB
testcase_14 AC 29 ms
21,376 KB
testcase_15 AC 19 ms
14,592 KB
testcase_16 AC 26 ms
22,144 KB
testcase_17 AC 9 ms
9,216 KB
testcase_18 AC 27 ms
23,040 KB
testcase_19 AC 28 ms
23,552 KB
testcase_20 AC 12 ms
9,856 KB
testcase_21 AC 8 ms
8,064 KB
testcase_22 AC 56 ms
44,504 KB
testcase_23 AC 57 ms
44,504 KB
testcase_24 AC 56 ms
44,504 KB
testcase_25 AC 64 ms
44,504 KB
testcase_26 AC 8 ms
8,576 KB
testcase_27 AC 64 ms
44,504 KB
testcase_28 AC 60 ms
44,504 KB
testcase_29 AC 59 ms
44,504 KB
testcase_30 AC 62 ms
44,504 KB
testcase_31 AC 59 ms
44,504 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;
using mint = modint998244353;

ll sum[26][202020];

int main() {
  string S; cin >> S;
  for (int i = 0; i < S.size(); i++) {
    for (int j = 0; j < 26; j++) {
      sum[j][i + 1] = sum[j][i] + (j == S[i] - 'A');
    }
  }
  ll ans = 0;
  for (int i = 0; i < S.size(); i++) {
    for (int j = 0; j < 26; j++) {
      if (j != S[i] - 'A' && sum[j][i + 1] >= 2) ans += sum[j][i + 1] * (sum[j][i + 1] - 1) / 2;
    }
  }
  cout << ans << endl;
  return 0;
}
0