結果
問題 | No.2419 MMA文字列2 |
ユーザー | くけ |
提出日時 | 2023-08-12 14:08:27 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 10 ms / 2,000 ms |
コード長 | 648 bytes |
コンパイル時間 | 4,521 ms |
コンパイル使用メモリ | 262,616 KB |
実行使用メモリ | 5,856 KB |
最終ジャッジ日時 | 2024-11-19 17:32:18 |
合計ジャッジ時間 | 5,670 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 30 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using namespace atcoder; typedef long long ll; #define rep(i, n) for (int i = 0; i < n; i++) #define chmin(x, y) x = min(x, y) #define chmax(x, y) x = max(x, y) int main(){ string s ; cin >> s ; vector<ll> G[26] ; rep(i,s.size()){ G[s[i]-'A'].push_back(i) ; } ll ans = 0 ; rep(i,26){ ll n , m ; n = m = G[i].size() ; rep(j,n){ if( n-j-2 < 0 ) continue; ll a = G[i][n-j-1] ; ans += ( s.size() - j - 1 - a ) * ( m - 1 ) ; m-- ; } } cout << ans << endl ; }