結果
| 問題 |
No.2419 MMA文字列2
|
| コンテスト | |
| ユーザー |
eve__fuyuki
|
| 提出日時 | 2024-11-15 17:12:59 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 34 ms / 2,000 ms |
| コード長 | 387 bytes |
| コンパイル時間 | 2,043 ms |
| コンパイル使用メモリ | 195,532 KB |
| 最終ジャッジ日時 | 2025-02-25 04:16:54 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 30 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
void fast_io() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
}
int main() {
fast_io();
string s;
cin >> s;
long long ans = 0;
vector<long long> cnt(26, 0);
for (char c : s) {
for (int i = 0; i < 26; i++) {
if (c != 'A' + i) {
ans += cnt[i] * (cnt[i] - 1) / 2;
}
}
cnt[c - 'A']++;
}
cout << ans << endl;
}
eve__fuyuki