結果
| 問題 |
No.171 スワップ文字列(Med)
|
| コンテスト | |
| ユーザー |
beet
|
| 提出日時 | 2018-12-06 15:57:58 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 7 ms / 1,000 ms |
| コード長 | 695 bytes |
| コンパイル時間 | 2,062 ms |
| コンパイル使用メモリ | 195,052 KB |
| 最終ジャッジ日時 | 2025-01-06 18:24:41 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 |
ソースコード
#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;
}
beet