結果

問題 No.2419 MMA文字列2
ユーザー ku_senjanku_senjan
提出日時 2023-08-12 13:57:56
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 497 ms / 2,000 ms
コード長 1,642 bytes
コンパイル時間 11,189 ms
コンパイル使用メモリ 440,804 KB
実行使用メモリ 295,808 KB
最終ジャッジ日時 2024-04-30 04:35:14
合計ジャッジ時間 18,021 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 128 ms
68,864 KB
testcase_13 AC 20 ms
13,568 KB
testcase_14 AC 246 ms
128,896 KB
testcase_15 AC 152 ms
80,640 KB
testcase_16 AC 262 ms
134,912 KB
testcase_17 AC 70 ms
42,368 KB
testcase_18 AC 270 ms
140,800 KB
testcase_19 AC 282 ms
144,896 KB
testcase_20 AC 77 ms
47,616 KB
testcase_21 AC 55 ms
34,304 KB
testcase_22 AC 497 ms
295,808 KB
testcase_23 AC 495 ms
295,588 KB
testcase_24 AC 488 ms
295,680 KB
testcase_25 AC 491 ms
295,808 KB
testcase_26 AC 61 ms
38,272 KB
testcase_27 AC 489 ms
295,628 KB
testcase_28 AC 493 ms
295,676 KB
testcase_29 AC 494 ms
295,680 KB
testcase_30 AC 492 ms
295,680 KB
testcase_31 AC 490 ms
295,444 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#ifdef SENJAN
#define _GLIBCXX_DEBUG
#else
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#endif
#include <bits/stdc++.h>
#include <atcoder/all>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace atcoder;
using ll=long long;
using ull=unsigned long long;
using ld=long double;
using bint = boost::multiprecision::cpp_int;
using graph=vector<vector<int>>;
template<class T> using min_priority_queue=priority_queue<T,vector<T>,greater<T>>;
constexpr int INF32=INT_MAX/2;
constexpr ll INF64=LLONG_MAX/2;
constexpr ld PI=3.14159265358979323846;
constexpr int dx[]={0,0,-1,1,-1,-1,1,1},dy[]={-1,1,0,0,-1,1,-1,1};
template<class T> inline bool chmax(T &a,T b){return a<b?a=b,true:false;}
template<class T> inline bool chmin(T &a,T b){return a>b?a=b,true:false;}
inline void dispYN(bool a){cout<<(a?"YES":"NO")<<endl;}
inline void dispYn(bool a){cout<<(a?"Yes":"No")<<endl;}
inline void dispyn(bool a){cout<<(a?"yes":"no")<<endl;}
void _main();
int main(){cin.tie(0)->sync_with_stdio(0);cout<<fixed<<setprecision(16);_main();}

void _main(){
  string s; cin >> s;
  int n = s.length();

  vector dp(n+1, vector(26, vector<ll>(3)));
  auto idx = [&](char c){ return c-'A'; };
  ll ans = 0;
  for(int i=0; i<26; i++){
    dp[0][i][0] = 1;
  }
  for(int i=0; i<n; i++){
    for(int j=0; j<26; j++){
      for(int k=0; k<=2; k++){
        dp[i+1][j][k] = dp[i][j][k];
      }
    }
    for(int j=0; j<2; j++){
      dp[i+1][idx(s[i])][j+1] += dp[i][idx(s[i])][j];
    }
    for(int j=0; j<26; j++){
      if(j!=idx(s[i])) ans += dp[i+1][j][2];
    }
  }
  cout << ans << endl;
}
0