結果
| 問題 |
No.171 スワップ文字列(Med)
|
| コンテスト | |
| ユーザー |
IL_msta
|
| 提出日時 | 2015-07-09 06:31:17 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,203 bytes |
| コンパイル時間 | 693 ms |
| コンパイル使用メモリ | 87,660 KB |
| 実行使用メモリ | 13,880 KB |
| 最終ジャッジ日時 | 2024-07-08 01:46:23 |
| 合計ジャッジ時間 | 3,329 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | AC * 5 WA * 1 TLE * 1 -- * 3 |
ソースコード
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <list>
#include <queue>
#include <vector>
#include <complex>
#include <set>
/////////
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;
/////////
typedef long long LL;
typedef long double LD;
/////////
using namespace::std;
/////////
const LL mod = 573;
LL cdp[1001][501];
LL ccc(int n,int k){
if(k<0){
return 0;
}
else if( n < k){
return 0;
}
//0<=k<=n
k = min(k,n-k);
if(k==0){
return 1;
}
else if( k == 1){
return n;
}
else if( cdp[n][k] != 0){
return cdp[n][k];
}
////////
LL ans = 0;
ans = ( ccc(n-1,k-1) + ccc(n-1,k) )%mod;
cdp[n][k] = ans;
return ans;
}
int main(void){
std::cin.tie(0);
std::ios::sync_with_stdio(false);
std::cout << std::fixed;//
cout << setprecision(10);//
string str;
cin>>str;
int N = str.size();
int s[26];
rep(i,26)s[i]=0;
rep(i,N){
++s[ str[i] - 'A' ];
}
sort(s,s+26);
LL ans=1;
int nokori = N;
rep(i,26){
ans *= ccc( nokori,s[i] );
ans %= mod;//mod
nokori -= s[i];
}
P(ans-1);
return 0;
}
IL_msta