結果

問題 No.171 スワップ文字列(Med)
ユーザー 👑 kmjpkmjp
提出日時 2015-03-22 23:26:01
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 29 ms / 1,000 ms
コード長 1,031 bytes
コンパイル時間 1,226 ms
コンパイル使用メモリ 145,832 KB
実行使用メモリ 33,380 KB
最終ジャッジ日時 2023-09-11 09:29:04
合計ジャッジ時間 2,292 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
33,180 KB
testcase_01 AC 29 ms
33,204 KB
testcase_02 AC 29 ms
33,184 KB
testcase_03 AC 29 ms
33,252 KB
testcase_04 AC 28 ms
33,336 KB
testcase_05 AC 29 ms
33,364 KB
testcase_06 AC 28 ms
33,300 KB
testcase_07 AC 29 ms
33,200 KB
testcase_08 AC 29 ms
33,356 KB
testcase_09 AC 29 ms
33,300 KB
testcase_10 AC 29 ms
33,236 KB
testcase_11 AC 28 ms
33,380 KB
testcase_12 AC 28 ms
33,196 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<to;x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

string S;
int L;
ll mo=573;
int num[26];

const int CN=2001;
ll C[CN][CN];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	FOR(i,CN) for(j=0;j<=i;j++) C[i][j]=(j==0||j==i)?1:(C[i-1][j-1]+C[i-1][j])%mo;
	
	cin>>S;
	L=S.size();
	FOR(i,S.size()) num[S[i]-'A']++;
	
	ll ret=1;
	FOR(i,26) if(num[i]) {
		ret = ret * C[L][num[i]] % mo;
		L-=num[i];
	}
	cout<<(ret+mo-1)%mo<<endl;
	
	
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}
0