結果

問題 No.329 全射
コンテスト
ユーザー 👑 tails
提出日時 2015-12-22 09:28:48
言語 C90
(gcc 12.4.0)
コンパイル:
gcc-12 -O2 -std=c90 -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
WA  
実行時間 -
コード長 895 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 317 ms
コンパイル使用メモリ 33,516 KB
最終ジャッジ日時 2026-02-23 20:14:59
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 8 WA * 32
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:3:1: warning: data definition has no type or storage class
    3 | noktbl[1010][1010];
      | ^~~~~~
main.c:11:1: warning: conflicting types for built-in function ‘pow’; expected ‘double(double,  double)’ [-Wbuiltin-declaration-mismatch]
   11 | pow(n,e){
      | ^~~
main.c:1:1: note: ‘pow’ is declared in header ‘<math.h>’
  +++ |+#include <math.h>
    1 | #define mod 1000000007
main.c:15:1: warning: data definition has no type or storage class
   15 | w[210];ln[210][210];li[210];u[210];a[210];ai;
      | ^
main.c:15:8: warning: data definition has no type or storage class
   15 | w[210];ln[210][210];li[210];u[210];a[210];ai;
      |        ^~
main.c:15:21: warning: data definition has no type or storage class
   15 | w[210];ln[210][210];li[210];u[210];a[210];ai;
      |                     ^~
main.c:15:29: warning: data definition has no type or storage class
   15 | w[210];ln[210][210];li[210];u[210];a[210];ai;
      |                             ^
main.c:15:36: warning: data definition has no type or storage class
   15 | w[210];ln[210][210];li[210];u[210];a[210];ai;
      |                                    ^
main.c:15:43: warning: data definition has no type or storage class
   15 | w[210];ln[210][210];li[210];u[210];a[210];ai;
      |                                           ^~
main.c:16:1: warning: data definition has no type or storage class
   16 | rtbl[1010][1010];
      | ^~~~
main.c: In function ‘main’:
main.c:18:9: warning: incompatible implicit declaration of built-in function ‘scanf’ [-Wbuiltin-declaration-mismatch]
   18 |         scanf("%d%d",&n,&m);
      |         ^~~~~
main.c:1:1: note: include ‘<stdio.h>’ or provide a declaration of ‘scanf’
  +++ |+#include <stdio.h>
    1 | #define mod 1000000007
main.c:27:17: warning: incompatible implicit declaration of built-in function ‘memset’ [-Wbuiltin-declaration-mismatch]
   27 |                 memset(u,0,sizeof u);
      |                 ^~~~~~
main.c:1:

ソースコード

diff #
raw source code

#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];
}

pow(n,e){
	return e?(e&1?n:1)*pow((int)((long long)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;
					}
					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