結果

問題 No.171 スワップ文字列(Med)
ユーザー yuustiyuusti
提出日時 2015-03-24 19:20:49
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,337 bytes
コンパイル時間 589 ms
コンパイル使用メモリ 86,140 KB
実行使用メモリ 7,616 KB
最終ジャッジ日時 2023-09-11 09:57:19
合計ジャッジ時間 1,351 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
7,504 KB
testcase_01 AC 4 ms
7,284 KB
testcase_02 AC 5 ms
7,344 KB
testcase_03 AC 5 ms
7,372 KB
testcase_04 AC 4 ms
7,368 KB
testcase_05 AC 4 ms
7,348 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 4 ms
7,372 KB
testcase_11 AC 5 ms
7,388 KB
testcase_12 AC 5 ms
7,612 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>
#include <array>
#include <climits>
#include <bitset>
#include <cassert>
#include <unordered_map>
#include <complex>

#ifdef _MSC_VER
#include <agents.h>
#endif

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define UNIQUE(v) (v).erase(unique(ALL(v)), (v).end())
#define MP make_pair
#define MT make_tuple

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;

int comb[1010][1010];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout.setf(ios::fixed);
	cout.precision(20);

	for (int i = 0; i <= 1000; ++i){
		comb[i][0] = 1;
		for (int j = 1; j <= i; ++j){
			comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
		}
	}

	string s;
	cin >> s;

	int cnt[256] = {};
	for (auto c : s) cnt[c]++;

	int n = s.size();

	const int m = 573;

	ll x = 1;
	rep(i, 256){
		x = x*comb[n][cnt[i]] % 573;
		n -= cnt[i];
	}

	cout << (x + m - 1) % m << endl;
}
0