結果

問題 No.171 スワップ文字列(Med)
ユーザー beetbeet
提出日時 2018-12-06 15:57:58
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 7 ms / 1,000 ms
コード長 695 bytes
コンパイル時間 2,139 ms
コンパイル使用メモリ 201,460 KB
実行使用メモリ 11,404 KB
最終ジャッジ日時 2023-10-12 02:46:38
合計ジャッジ時間 2,800 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
11,260 KB
testcase_01 AC 6 ms
11,260 KB
testcase_02 AC 7 ms
11,380 KB
testcase_03 AC 6 ms
11,380 KB
testcase_04 AC 6 ms
11,268 KB
testcase_05 AC 7 ms
11,388 KB
testcase_06 AC 7 ms
11,268 KB
testcase_07 AC 7 ms
11,264 KB
testcase_08 AC 7 ms
11,276 KB
testcase_09 AC 7 ms
11,404 KB
testcase_10 AC 6 ms
11,384 KB
testcase_11 AC 7 ms
11,376 KB
testcase_12 AC 7 ms
11,328 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
const Int MOD = 573;
const Int MAX = 1010;
Int dp[MAX][MAX];
signed main(){
  string s;
  cin>>s;
  Int n=s.size();
  vector<Int> cnt(26,0);
  for(char c:s) cnt[c-'A']++;

  memset(dp,0,sizeof(dp));
  dp[0][0]=1;
  for(Int i=1;i<MAX;i++)
    for(Int j=0;j<=i;j++)
      dp[i][j]=(dp[i-1][j]+(j?dp[i-1][j-1]:0))%MOD;

  Int ans=1,res=n;
  for(Int x:cnt){
    ans*=dp[res][x];
    ans%=MOD;
    res-=x;
  }
  cout<<(ans+MOD-1)%MOD<<endl;
  return 0;
}
0