結果
問題 |
No.2419 MMA文字列2
|
ユーザー |
|
提出日時 | 2024-04-07 11:40:14 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 832 bytes |
コンパイル時間 | 4,716 ms |
コンパイル使用メモリ | 257,284 KB |
最終ジャッジ日時 | 2025-02-20 22:43:28 |
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 14 TLE * 3 -- * 13 |
ソースコード
#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; }