結果
| 問題 | No.2419 MMA文字列2 |
| コンテスト | |
| ユーザー |
inkyaman
|
| 提出日時 | 2024-03-25 20:48:02 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 5 ms / 2,000 ms |
| コード長 | 652 bytes |
| 記録 | |
| コンパイル時間 | 664 ms |
| コンパイル使用メモリ | 140,776 KB |
| 実行使用メモリ | 6,528 KB |
| 最終ジャッジ日時 | 2026-07-04 06:36:35 |
| 合計ジャッジ時間 | 1,844 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 30 |
ソースコード
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <cmath>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <iomanip>
#include <climits>
#include <functional>
#include <cassert>
#include <tuple>
using namespace std;
using ll = long long;
string S;
int main() {
cin >> S;
int N = S.size();
vector<ll> sum(1010,0), cnt(1010,0);
for(auto c : S) sum[c]++;
ll ans = 0;
for(int i = 0; i < N; ++i) {
ans += cnt[S[i]]*(N-i-sum[S[i]]+cnt[S[i]]);
cnt[S[i]]++;
}
cout << ans << endl;
}
inkyaman