結果

問題 No.2419 MMA文字列2
ユーザー shop_oneshop_one
提出日時 2023-08-12 14:03:32
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 409 ms / 2,000 ms
コード長 822 bytes
コンパイル時間 2,100 ms
コンパイル使用メモリ 112,896 KB
実行使用メモリ 14,384 KB
最終ジャッジ日時 2024-04-30 04:50:59
合計ジャッジ時間 15,448 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 7 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 89 ms
5,772 KB
testcase_13 AC 14 ms
5,376 KB
testcase_14 AC 181 ms
7,936 KB
testcase_15 AC 106 ms
6,100 KB
testcase_16 AC 184 ms
8,120 KB
testcase_17 AC 55 ms
5,376 KB
testcase_18 AC 188 ms
8,384 KB
testcase_19 AC 197 ms
8,636 KB
testcase_20 AC 61 ms
5,376 KB
testcase_21 AC 42 ms
5,376 KB
testcase_22 AC 375 ms
14,224 KB
testcase_23 AC 404 ms
14,248 KB
testcase_24 AC 409 ms
14,244 KB
testcase_25 AC 376 ms
14,384 KB
testcase_26 AC 48 ms
5,376 KB
testcase_27 AC 398 ms
14,276 KB
testcase_28 AC 399 ms
14,248 KB
testcase_29 AC 370 ms
14,244 KB
testcase_30 AC 403 ms
14,380 KB
testcase_31 AC 399 ms
14,248 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// 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;
}
0