結果

問題 No.118 門松列(2)
ユーザー m1025o1184tm1025o1184t
提出日時 2019-12-02 04:31:17
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 793 bytes
コンパイル時間 1,375 ms
コンパイル使用メモリ 171,092 KB
実行使用メモリ 11,676 KB
最終ジャッジ日時 2024-05-01 23:54:06
合計ジャッジ時間 8,011 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 TLE -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;

const int mod = 1000000007;

int C[500][500];

void comb() {
	C[0][0] = 1;
	for (int i = 0; i <= 400; ++i) {
		for (int j = 0; j <=i; ++j) {
			C[i + 1][j] += C[i][j] % mod;
			C[i + 1][j + 1] += C[i][j] % mod;
		}
	}
}

int main() {
	int n;
	cin >> n;
	vector<int> A(n);
	rep(i, n) cin >> A[i];
	comb();
	vector<int> res = A;
	auto result = unique(res.begin(), res.end());
	res.erase(result, res.end());
	if (res.size() == A.size()) {
		int ans = C[n][3] % mod;
		cout << ans << endl;
		return 0;
	}
	int sol = 1;
	for (int i = 0; i < res.size(); ++i) {
		int k = count(A.begin(), A.end(), res[i]);
		sol *= k;
		sol %= mod;
	}
	int ans2 = C[res.size()][3] * sol % mod;
	cout << ans2 << endl;
	return 0;
}
0