結果
問題 | No.2419 MMA文字列2 |
ユーザー | shop_one |
提出日時 | 2023-08-12 14:03:32 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 428 ms / 2,000 ms |
コード長 | 822 bytes |
コンパイル時間 | 1,244 ms |
コンパイル使用メモリ | 112,496 KB |
実行使用メモリ | 14,376 KB |
最終ジャッジ日時 | 2024-11-19 17:12:48 |
合計ジャッジ時間 | 7,258 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 30 |
ソースコード
// I SELL YOU...! #include<iostream> #include<vector> #include<algorithm> #include<functional> #include<queue> #include<chrono> #include<iomanip> #include<map> #include<set> using namespace std; using ll = long long; using P = pair<ll,ll>; using TP = tuple<ll,ll,ll>; void init_io(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(18); } signed main(){ init_io(); string s; cin >> s; ll n = s.size(); ll ans = 0; for (char c='A'; c<='Z'; c++) { vector<vector<ll>> dp(n+1, vector<ll> (3, 0)); ll tmp = 0; for (int i=0;i<n;i++) { dp[i+1][0] = dp[i][0]; dp[i+1][1] = dp[i][1]; if (s[i] == c) { dp[i+1][0] += 1; dp[i+1][1] += dp[i][0]; } else { tmp += dp[i+1][1]; } } ans += tmp; } cout << ans << endl; }