結果

問題 No.2419 MMA文字列2
ユーザー 👑 Nafmo2Nafmo2
提出日時 2023-07-22 17:51:02
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 72 ms / 2,000 ms
コード長 1,619 bytes
コンパイル時間 12,346 ms
コンパイル使用メモリ 425,464 KB
実行使用メモリ 51,996 KB
最終ジャッジ日時 2023-10-24 00:20:46
合計ジャッジ時間 15,434 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 16 ms
14,188 KB
testcase_13 AC 4 ms
5,236 KB
testcase_14 AC 28 ms
24,220 KB
testcase_15 AC 18 ms
16,300 KB
testcase_16 AC 30 ms
25,276 KB
testcase_17 AC 10 ms
9,964 KB
testcase_18 AC 33 ms
26,332 KB
testcase_19 AC 35 ms
26,860 KB
testcase_20 AC 11 ms
10,756 KB
testcase_21 AC 8 ms
8,644 KB
testcase_22 AC 69 ms
51,996 KB
testcase_23 AC 70 ms
51,996 KB
testcase_24 AC 69 ms
51,996 KB
testcase_25 AC 69 ms
51,996 KB
testcase_26 AC 9 ms
9,172 KB
testcase_27 AC 68 ms
51,996 KB
testcase_28 AC 72 ms
51,996 KB
testcase_29 AC 72 ms
51,996 KB
testcase_30 AC 70 ms
51,996 KB
testcase_31 AC 70 ms
51,996 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// clang-format off
#include <bits/stdc++.h>
#include <iterator>
#include <atcoder/all>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/integer.hpp>
typedef long long int ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n) for(ll i=0;i<signed(n);i++)
#define EREP(i,n) for(ll i=1;i<=signed(n);i++)
#define ALL(x) std::begin(x), std::end(x)
using namespace std;
using namespace atcoder;
using boost::multiprecision::cpp_int;
namespace mp = boost::multiprecision;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X <<":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const ll INF = 9e18;
typedef std::pair<ll, ll> P;
struct edge { ll to, cost; };
#define VMAX 100000
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template <class T> T vgcd(T m, T n) {return std::gcd(m, n);}
template <class T, class... Args> T vgcd(T a, Args... args) {return vgcd(a, vgcd(args...));}
// clang-format on

int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};


int main(void) {
  ll ans = 0;
  ll N;
  string S;
  cin>>S;
  N=S.size();
  reverse(ALL(S));
  vector<vector<ll>> A(N+1,vector<ll>(26));
  REP(i,N){
    A[i+1][S[i]-'A']++;
  }
  REP(i,N){
    REP(j,26){
      A[i+1][j]+=A[i][j];
    }
  }
  REP(i,N-2){
    REP(j,26){
      if(j+'A'==S[i])continue;
      ans+=(A[N][j] - A[i][j]) * (A[N][j] - A[i][j]-1)/2;
    }
  }
  cout<<ans<<endl;
}
0