結果
| 問題 | No.2419 MMA文字列2 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-04-07 11:40:14 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 832 bytes |
| 記録 | |
| コンパイル時間 | 3,226 ms |
| コンパイル使用メモリ | 281,752 KB |
| 実行使用メモリ | 12,024 KB |
| 最終ジャッジ日時 | 2026-07-04 10:58:38 |
| 合計ジャッジ時間 | 17,665 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 18 TLE * 3 -- * 9 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;
using mint = modint998244353;
int main() {
string S; cin >> S;
map<char, vector<int>> mp;
for (int i = 0; i < S.size(); i++) {
mp[S[i]].push_back(i);
}
ll ans = 0;
for (int i = 0; i < S.size(); i++) {
if (mp[S[i]].size() >= 2) {
int pos1 = lower_bound(mp[S[i]].begin(), mp[S[i]].end(), i) - mp[S[i]].begin();
if (pos1 < mp[S[i]].size() - 1) {
for (int j = pos1 + 1; j < mp[S[i]].size(); j++) {
int siz = max(0, (int)mp[S[i]].size() - j - 1);
ans += S.size() - mp[S[i]][j] - 1 - siz;
//cout << S[i] << ' ' << S.size() - mp[S[i]][pos1 + 1] - 1 - siz << endl;
}
}
}
}
cout << ans << endl;
return 0;
}