結果
問題 | No.2419 MMA文字列2 |
ユーザー |
![]() |
提出日時 | 2023-08-12 13:37:42 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 7 ms / 2,000 ms |
コード長 | 392 bytes |
コンパイル時間 | 1,532 ms |
コンパイル使用メモリ | 167,956 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-19 15:44:49 |
合計ジャッジ時間 | 2,611 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 30 |
ソースコード
#include <bits/stdc++.h>using namespace std;int main(){string S;cin >> S;int N = S.size();long long ans = 0;vector<int> cnt(26, 0);for (int i = 0; i < N; i++){int p = S[i] - 'A';ans += (long long) cnt[p] * (N - 1 - i);cnt[p]++;}for (int i = 0; i < 26; i++){ans -= (long long) cnt[i] * (cnt[i] - 1) * (cnt[i] - 2) / 6;}cout << ans << endl;}