結果

問題 No.329 全射
ユーザー piyoko_212piyoko_212
提出日時 2015-12-23 12:18:56
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 553 ms / 2,000 ms
コード長 1,088 bytes
コンパイル時間 1,169 ms
コンパイル使用メモリ 36,804 KB
実行使用メモリ 19,332 KB
最終ジャッジ日時 2023-10-19 01:44:58
合計ジャッジ時間 8,029 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
19,172 KB
testcase_01 AC 41 ms
19,172 KB
testcase_02 AC 42 ms
19,172 KB
testcase_03 AC 41 ms
19,172 KB
testcase_04 AC 42 ms
19,172 KB
testcase_05 AC 42 ms
19,172 KB
testcase_06 AC 41 ms
19,172 KB
testcase_07 AC 42 ms
19,172 KB
testcase_08 AC 42 ms
19,172 KB
testcase_09 AC 41 ms
19,172 KB
testcase_10 AC 41 ms
19,172 KB
testcase_11 AC 42 ms
19,172 KB
testcase_12 AC 42 ms
19,172 KB
testcase_13 AC 507 ms
19,324 KB
testcase_14 AC 370 ms
19,300 KB
testcase_15 AC 336 ms
19,292 KB
testcase_16 AC 339 ms
19,292 KB
testcase_17 AC 425 ms
19,312 KB
testcase_18 AC 464 ms
19,316 KB
testcase_19 AC 553 ms
19,332 KB
testcase_20 AC 484 ms
19,320 KB
testcase_21 AC 413 ms
19,308 KB
testcase_22 AC 553 ms
19,332 KB
testcase_23 AC 66 ms
19,252 KB
testcase_24 AC 67 ms
19,252 KB
testcase_25 AC 94 ms
19,288 KB
testcase_26 AC 82 ms
19,264 KB
testcase_27 AC 48 ms
19,212 KB
testcase_28 AC 43 ms
19,180 KB
testcase_29 AC 46 ms
19,204 KB
testcase_30 AC 45 ms
19,192 KB
testcase_31 AC 42 ms
19,172 KB
testcase_32 AC 46 ms
19,208 KB
testcase_33 AC 51 ms
19,308 KB
testcase_34 AC 50 ms
19,300 KB
testcase_35 AC 53 ms
19,320 KB
testcase_36 AC 51 ms
19,312 KB
testcase_37 AC 50 ms
19,296 KB
testcase_38 AC 51 ms
19,308 KB
testcase_39 AC 51 ms
19,308 KB
testcase_40 AC 53 ms
19,320 KB
testcase_41 AC 50 ms
19,300 KB
testcase_42 AC 54 ms
19,320 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:21:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   21 |         int a,b;scanf("%d%d",&a,&b);
      |                 ~~~~~^~~~~~~~~~~~~~
main.cpp:22:34: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   22 |         for(int i=0;i<a;i++)scanf("%d",c+i);
      |                             ~~~~~^~~~~~~~~~
main.cpp:27:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   27 |                 int p,q;scanf("%d%d",&p,&q);p--;q--;
      |                         ~~~~~^~~~~~~~~~~~~~

ソースコード

diff #

#include<stdio.h>
#include<algorithm>
using namespace std;
long long mod=1000000007;
long long rj[1100][1100];
long long C[1100][1100];
int c[110000];
int g[210][210];
int main(){
	for(int i=0;i<1100;i++){
		rj[i][0]=1;
		for(int j=1;j<1100;j++)rj[i][j]=rj[i][j-1]*i%mod;
	}
	C[0][0]=1;
	for(int i=0;i<1050;i++){
		for(int j=0;j<=i;j++){
			C[i+1][j]=(C[i+1][j]+C[i][j])%mod;
			C[i+1][j+1]=(C[i+1][j+1]+C[i][j])%mod;
		}
	}
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++)scanf("%d",c+i);
	for(int i=0;i<a;i++)for(int j=0;j<a;j++)g[i][j]=-999999999;
	for(int i=0;i<a;i++)g[i][i]=999999999;
	
	for(int i=0;i<b;i++){
		int p,q;scanf("%d%d",&p,&q);p--;q--;
		g[p][q]=min(c[q],c[p]);
	}
	for(int k=0;k<a;k++)for(int i=0;i<a;i++)for(int j=0;j<a;j++)g[i][j]=max(g[i][j],min(g[i][k],g[k][j]));
	long long ret=0;
	for(int i=0;i<a;i++)for(int j=0;j<a;j++){
		if(g[i][j]>=c[j]){
			for(int k=0;k<c[j];k++){
				long long tmp=rj[c[j]-k][c[i]]*C[c[j]][k]%mod;
				if(k%2)ret=(ret+mod-tmp)%mod;
				else ret=(ret+tmp)%mod;
			}
		//	printf("%d %d: %lld\n",i,j,ret);
		}
	}
	printf("%lld\n",ret);
}
0