結果

問題 No.329 全射
ユーザー TawaraTawara
提出日時 2015-12-26 05:28:31
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 18 ms / 2,000 ms
コード長 710 bytes
コンパイル時間 243 ms
コンパイル使用メモリ 36,196 KB
実行使用メモリ 9,676 KB
最終ジャッジ日時 2023-10-19 03:59:14
合計ジャッジ時間 1,819 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
9,448 KB
testcase_01 AC 4 ms
9,448 KB
testcase_02 AC 5 ms
9,448 KB
testcase_03 AC 5 ms
9,448 KB
testcase_04 AC 4 ms
9,448 KB
testcase_05 AC 5 ms
9,448 KB
testcase_06 AC 5 ms
9,448 KB
testcase_07 AC 5 ms
9,448 KB
testcase_08 AC 5 ms
9,448 KB
testcase_09 AC 4 ms
9,448 KB
testcase_10 AC 5 ms
9,448 KB
testcase_11 AC 4 ms
9,448 KB
testcase_12 AC 5 ms
9,448 KB
testcase_13 AC 17 ms
9,668 KB
testcase_14 AC 11 ms
9,632 KB
testcase_15 AC 11 ms
9,624 KB
testcase_16 AC 13 ms
9,624 KB
testcase_17 AC 14 ms
9,648 KB
testcase_18 AC 16 ms
9,656 KB
testcase_19 AC 18 ms
9,676 KB
testcase_20 AC 16 ms
9,664 KB
testcase_21 AC 14 ms
9,644 KB
testcase_22 AC 17 ms
9,676 KB
testcase_23 AC 8 ms
9,564 KB
testcase_24 AC 8 ms
9,564 KB
testcase_25 AC 11 ms
9,612 KB
testcase_26 AC 8 ms
9,580 KB
testcase_27 AC 5 ms
9,504 KB
testcase_28 AC 5 ms
9,460 KB
testcase_29 AC 5 ms
9,496 KB
testcase_30 AC 4 ms
9,480 KB
testcase_31 AC 5 ms
9,448 KB
testcase_32 AC 5 ms
9,496 KB
testcase_33 AC 10 ms
9,640 KB
testcase_34 AC 10 ms
9,632 KB
testcase_35 AC 12 ms
9,656 KB
testcase_36 AC 12 ms
9,648 KB
testcase_37 AC 9 ms
9,628 KB
testcase_38 AC 10 ms
9,640 KB
testcase_39 AC 10 ms
9,644 KB
testcase_40 AC 12 ms
9,664 KB
testcase_41 AC 10 ms
9,632 KB
testcase_42 AC 13 ms
9,664 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:22:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   22 |         scanf("%d%d",&N,&M);
      |         ~~~~~^~~~~~~~~~~~~~
main.cpp:23:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   23 |         rep(i,N)scanf("%d",w+i);
      |                 ~~~~~^~~~~~~~~~
main.cpp:25:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   25 |         rep(i,M){scanf("%d%d",&x,&y);x--; E[x][--y] = w[x];}
      |                  ~~~~~^~~~~~~~~~~~~~

ソースコード

diff #

#include <algorithm>
#include <stdio.h>

using namespace std;

typedef long long LL;

#define range(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) range(i,0,n)
#define P 1000000007
#define W 1001

LL D[W][W];
int w[W-1],E[300][300];

int main(){
	int N,M,x,y;
	LL A = 0;
	rep(i,W)rep(j,W) D[i][j] = 0;
	D[0][0] = 1;
	rep(i,W-1) rep(j,i+1) D[i+1][j+1] = (LL) (j+1)*(D[i][j+1]+D[i][j])%P;
	scanf("%d%d",&N,&M);
	rep(i,N)scanf("%d",w+i);
	rep(i,N){rep(j,N) E[i][j] = 0; E[i][i] = w[i];}
	rep(i,M){scanf("%d%d",&x,&y);x--; E[x][--y] = w[x];}
	rep(k,N) rep(i,N) rep(j,N) E[i][j] = max(E[i][j],min(E[i][k],E[k][j]));
	rep(i,N) rep(j,N) if(w[j] <= E[i][j]) A = (A+D[w[i]][w[j]])%P;
	printf("%lld\n",A);
	return 0;
}
0