結果
問題 | No.2419 MMA文字列2 |
ユーザー |
|
提出日時 | 2023-08-12 15:22:40 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 245 ms / 2,000 ms |
コード長 | 559 bytes |
コンパイル時間 | 2,116 ms |
コンパイル使用メモリ | 197,256 KB |
最終ジャッジ日時 | 2025-02-16 06:16:39 |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 30 |
ソースコード
#include <bits/stdc++.h>using namespace std;using ll = long long;int main() {string s;cin >> s;vector<vector<int>> v(26);for(int i = 0; i < s.size(); i++) {v[s[i] - 'A'].push_back(i);}ll ans = 0;for(int c = 0; c < 26; c++) {if(v[c].size() <= 1) continue;for(int i = 1; i < v[c].size(); i++) {for(int d = 0; d < 26; d++) {if(v[d].empty() or c == d) continue;int x = v[d].end() - upper_bound(v[d].begin(), v[d].end(), v[c][i]);ans += (ll)i * x;}}}cout << ans << endl;}