結果

問題 No.329 全射
ユーザー tailstails
提出日時 2015-12-22 10:35:24
言語 C90
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 949 bytes
コンパイル時間 193 ms
コンパイル使用メモリ 23,816 KB
実行使用メモリ 7,012 KB
最終ジャッジ日時 2023-10-18 22:33:07
合計ジャッジ時間 5,651 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 1 ms
4,348 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 4 ms
4,768 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:4:1: warning: data definition has no type or storage class
    4 | noktbl[1010][1010];
      | ^~~~~~
main.c:4:1: warning: type defaults to ‘int’ in declaration of ‘noktbl’ [-Wimplicit-int]
main.c:5:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
    5 | nok(n,k){
      | ^~~
main.c: In function ‘nok’:
main.c:5:1: warning: type of ‘n’ defaults to ‘int’ [-Wimplicit-int]
main.c:5:1: warning: type of ‘k’ defaults to ‘int’ [-Wimplicit-int]
main.c: At top level:
main.c:12:11: warning: conflicting types for built-in function ‘pow’; expected ‘double(double,  double)’ [-Wbuiltin-declaration-mismatch]
   12 | long long pow(n,e)long long n;{
      |           ^~~
main.c:2:1: note: ‘pow’ is declared in header ‘<math.h>’
    1 | #include <assert.h>
  +++ |+#include <math.h>
    2 | #define mod 1000000007
main.c: In function ‘pow’:
main.c:12:11: warning: type of ‘e’ defaults to ‘int’ [-Wimplicit-int]
   12 | long long pow(n,e)long long n;{
      |           ^~~
main.c: At top level:
main.c:16:1: warning: data definition has no type or storage class
   16 | w[210];ln[210][210];li[210];u[210];a[210];ai;
      | ^
main.c:16:1: warning: type defaults to ‘int’ in declaration of ‘w’ [-Wimplicit-int]
main.c:16:8: warning: data definition has no type or storage class
   16 | w[210];ln[210][210];li[210];u[210];a[210];ai;
      |        ^~
main.c:16:8: warning: type defaults to ‘int’ in declaration of ‘ln’ [-Wimplicit-int]
main.c:16:21: warning: data definition has no type or storage class
   16 | w[210];ln[210][210];li[210];u[210];a[210];ai;
      |                     ^~
main.c:16:21: warning: type defaults to ‘int’ in declaration of ‘li’ [-Wimplicit-int]
main.c:16:29: warning: data definition has no type or storage class
   16 | w[210];ln[210][210];li[210];u[210];a[210];ai;
      |                             ^
main.c:16:29: warning: type defaults to ‘int’ in declaration of ‘u’

ソースコード

diff #

#include <assert.h>
#define mod 1000000007

noktbl[1010][1010];
nok(n,k){
	if(!noktbl[n][k]){
		noktbl[n][k]=k==0||k==n?1:(nok(n-1,k)+nok(n-1,k-1))%mod;
	}
	return noktbl[n][k];
}

long long pow(n,e)long long n;{
	return e?(e&1?n:1)*pow(n*n%mod,e/2)%mod:1;
}

w[210];ln[210][210];li[210];u[210];a[210];ai;
rtbl[1010][1010];

main(i,j,k,l,m,n,r,s,t){
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;++i)scanf("%d",w+i);
	for(k=0;k<m;++k){
		scanf("%d%d",&i,&j);
		ln[i][li[i]++]=j;
	}
	r=0;

	for(k=1;k<=n;++k){
		memset(u,0,sizeof u);
		u[k]++;
		ai=0;
		a[ai++]=k|w[k]<<8;
		while(ai){
			l=a[--ai];
			s=l>>8;
			l&=255;
			t=w[l];
			if(s>=t){
				if(!rtbl[s][t]){
					long long h=0;
					for(i=1;i<=t;++i){
						h=(nok(t,i)*pow(i,s)-h+mod)%mod;
					}
					assert(h>=0);
					rtbl[s][t]=h%mod;
				}
				r=(r+rtbl[s][t])%mod;
				s=t;
			}
	
			for(i=0;j=ln[l][i];++i){
				if(!u[j]++){
					a[ai++]=j|s<<8;
				}
			}
		}
	}
	printf("%d",r);
	return 0;
}
0