結果
| 問題 | No.2419 MMA文字列2 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-08-12 14:55:47 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 5 ms / 2,000 ms |
| コード長 | 750 bytes |
| 記録 | |
| コンパイル時間 | 495 ms |
| コンパイル使用メモリ | 90,268 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-05-14 02:50:18 |
| 合計ジャッジ時間 | 1,792 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 30 |
ソースコード
using namespace std;
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
int main(){
string S;
cin >> S;
int S_len = S.length();
vector<vector<int>> chars_indexes(26, vector<int>(0));
for (int i = 0; i < S_len; i++){
chars_indexes.at(S.at(i)-65).push_back(i);
}
long long ans = 0;
for (auto indexes : chars_indexes){
if (indexes.size() < 2){
continue;
}
long long last_number = S_len - indexes.back() - 1;
int count = 0;
for (int i = indexes.size()-2; i >= 0; i--){
count ++;
ans += last_number;
last_number += S_len - indexes.at(i) - 1 - count;
}
}
cout << ans << endl;
}