結果

問題 No.118 門松列(2)
ユーザー tsukio
提出日時 2016-03-05 20:53:25
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 699 bytes
コンパイル時間 856 ms
コンパイル使用メモリ 72,012 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-09-24 14:28:37
合計ジャッジ時間 1,727 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 3 WA * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <unordered_map>
#include <limits>
using namespace std;

int main() {
	int n;
	cin >> n;

	unordered_map<string, int> map;
	string len;
	for (int i = 0; i < n; i++) {
		cin >> len;
		map[len]++;
	}

	const int r = 3;
	long long divided = 1;
	int divisor = 1;
	int not_overlap_count = map.size();
	for (int i = 0; i < r; i++) {
		divided *= not_overlap_count - i;
		divisor *= r - i;
	}

	long long pattern = divided / divisor;
	for (auto keyValue : map) {
		pattern *= keyValue.second;
	}

	long long res;
	if (numeric_limits<int>::max() < pattern) {
		res = pattern % 1000000000 + 7;
	}
	else {
		res = pattern;
	}

	cout << res << endl;

	return 0;
}
0