結果
問題 | No.2419 MMA文字列2 |
ユーザー |
|
提出日時 | 2023-08-12 13:51:22 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 13 ms / 2,000 ms |
コード長 | 412 bytes |
コンパイル時間 | 1,723 ms |
コンパイル使用メモリ | 194,332 KB |
最終ジャッジ日時 | 2025-02-16 03:47:40 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 30 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { string S; cin >> S; int N(S.size()); ll ans(0); vector P(26, 0LL); for(int i = 0; i < N; i++) { P[S[i]-'A']++; for(int j = 0; j < 26; j++) { if(j == S[i]-'A') continue; ans += (ll)P[j] * (ll)(P[j] - 1) / 2LL; } } cout << ans << endl; return 0; }