結果

問題 No.171 スワップ文字列(Med)
ユーザー ttakanottakano
提出日時 2017-12-06 21:29:27
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 29 ms / 1,000 ms
コード長 824 bytes
コンパイル時間 1,859 ms
コンパイル使用メモリ 144,588 KB
実行使用メモリ 64,824 KB
最終ジャッジ日時 2023-08-19 09:53:12
合計ジャッジ時間 3,231 ms
ジャッジサーバーID
(参考情報)
judge9 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
51,800 KB
testcase_01 AC 21 ms
27,284 KB
testcase_02 AC 21 ms
27,264 KB
testcase_03 AC 21 ms
27,008 KB
testcase_04 AC 21 ms
27,068 KB
testcase_05 AC 21 ms
26,996 KB
testcase_06 AC 21 ms
26,992 KB
testcase_07 AC 26 ms
61,052 KB
testcase_08 AC 29 ms
64,824 KB
testcase_09 AC 27 ms
62,848 KB
testcase_10 AC 27 ms
62,908 KB
testcase_11 AC 27 ms
62,968 KB
testcase_12 AC 27 ms
63,068 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define printall(n,array) for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;
#define U() cout<<endl;
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<int, PI> V;
typedef vector<int> VE;
const ll mod = 1000000007; //10^9+7

string s;
ll cnt[27];

ll ncr[10010][10010];


int main(){
  cin>>s;
  REP(i,s.size())REP(j,26)if(s[i]-'A'==j)cnt[j]++;
  //print(s.size());///
  //printall(26,cnt);///
  REP(i,2001)REP(j,i+1)ncr[i][j]=(j==0||j==i)?1:(ncr[i-1][j-1]+ncr[i-1][j])%573;
  ll ret=1;
  ll rest=s.size();
  REP(i,26)if(cnt[i]){
    ret=ret*ncr[rest][cnt[i]]%573;
    rest-=cnt[i];
    //print(i<<" "<<ret<<" "<<rest)///
  }

  print((ret+573-1)%573);
}
0