結果
| 問題 | No.329 全射 |
| コンテスト | |
| ユーザー |
👑 tails
|
| 提出日時 | 2015-12-22 10:35:24 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 949 bytes |
| 記録 | |
| コンパイル時間 | 275 ms |
| コンパイル使用メモリ | 23,424 KB |
| 実行使用メモリ | 7,396 KB |
| 最終ジャッジ日時 | 2024-09-18 18:33:15 |
| 合計ジャッジ時間 | 5,618 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 11 WA * 29 |
コンパイルメッセージ
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’
ソースコード
#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;
}
tails