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