結果

問題 No.329 全射
ユーザー latte0119latte0119
提出日時 2016-05-24 21:25:23
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 26 ms / 2,000 ms
コード長 1,321 bytes
コンパイル時間 825 ms
コンパイル使用メモリ 81,372 KB
実行使用メモリ 7,552 KB
最終ジャッジ日時 2024-04-16 12:22:13
合計ジャッジ時間 2,565 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
7,296 KB
testcase_01 AC 6 ms
7,296 KB
testcase_02 AC 6 ms
7,296 KB
testcase_03 AC 6 ms
7,296 KB
testcase_04 AC 6 ms
7,296 KB
testcase_05 AC 6 ms
7,296 KB
testcase_06 AC 6 ms
7,296 KB
testcase_07 AC 6 ms
7,296 KB
testcase_08 AC 6 ms
7,424 KB
testcase_09 AC 7 ms
7,296 KB
testcase_10 AC 6 ms
7,296 KB
testcase_11 AC 6 ms
7,424 KB
testcase_12 AC 6 ms
7,552 KB
testcase_13 AC 25 ms
7,424 KB
testcase_14 AC 15 ms
7,424 KB
testcase_15 AC 16 ms
7,424 KB
testcase_16 AC 19 ms
7,424 KB
testcase_17 AC 20 ms
7,552 KB
testcase_18 AC 25 ms
7,424 KB
testcase_19 AC 26 ms
7,424 KB
testcase_20 AC 24 ms
7,552 KB
testcase_21 AC 20 ms
7,424 KB
testcase_22 AC 24 ms
7,552 KB
testcase_23 AC 11 ms
7,424 KB
testcase_24 AC 11 ms
7,552 KB
testcase_25 AC 15 ms
7,552 KB
testcase_26 AC 11 ms
7,424 KB
testcase_27 AC 7 ms
7,168 KB
testcase_28 AC 6 ms
7,424 KB
testcase_29 AC 7 ms
7,296 KB
testcase_30 AC 6 ms
7,424 KB
testcase_31 AC 6 ms
7,296 KB
testcase_32 AC 6 ms
7,424 KB
testcase_33 AC 14 ms
7,424 KB
testcase_34 AC 13 ms
7,552 KB
testcase_35 AC 16 ms
7,552 KB
testcase_36 AC 14 ms
7,552 KB
testcase_37 AC 12 ms
7,552 KB
testcase_38 AC 14 ms
7,424 KB
testcase_39 AC 14 ms
7,296 KB
testcase_40 AC 16 ms
7,296 KB
testcase_41 AC 12 ms
7,424 KB
testcase_42 AC 17 ms
7,424 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<cstdio>
#include<algorithm>
#include<vector>
#include<iostream>
#include<queue>
#include<stack>
#include<cstring>
#include<string>
#include<map>
#include<set>
#include<sstream>
#include<bitset>
#include<numeric>
#include<climits>
#include<complex>
using namespace std;

typedef long long ll;

template<typename A,typename B>inline void chmin(A &a, B b) { if (a > b)a = b; }
template<typename A,typename B>inline void chmax(A &a, B b) { if (a < b)a = b; }

const int mod = 1000000007;

int N, M;
int W[200];

int f[200][200];
int dp[1010][1010];

signed main() {
	cin >> N >> M;
	for (int i = 0; i < N; i++)cin >> W[i];

	for (int i = 0; i < N; i++)f[i][i] = W[i];

	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		f[a][b] = min(W[a], W[b]);
	}

	for (int k = 0; k < N; k++) {
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				chmax(f[i][j], min(f[i][k], f[k][j]));
			}
		}
	}

	dp[1][1] = 1;
	for (int i = 2; i <= 1000; i++) {
		for (int j = 1; j <= 1000; j++) {
			dp[i][j] = (ll)j*(dp[i - 1][j - 1] + dp[i - 1][j]) % mod;
		}
	}

	int ans = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (f[i][j] >= W[j])ans = (ans + dp[W[i]][W[j]]) % mod;
		}
	}
	cout << ans << endl;
	return 0;
}
0