记录编号 | 182346 | 评测结果 | AAAAAAAAAA | ||
---|---|---|---|---|---|
题目名称 | [ZJOI 2005] 沼泽鳄鱼 | 最终得分 | 100 | ||
用户昵称 | 是否通过 | 通过 | |||
代码语言 | C++ | 运行时间 | 0.076 s | ||
提交时间 | 2015-08-27 19:08:58 | 内存使用 | 0.47 MiB | ||
#include<cstdio> #include<cstring> #include<iostream> using namespace std; typedef long long LL; int N,M,S,E,K,F; int mod=10000; class miku { public: int n,m; int s[60][60]; miku() { n=m=0; memset(s,0,sizeof(s)); } void make(int a) { n=m=a; for(int i=0;i<n;i++) s[i][i]=1; } void print() { cout<<n<<" "<<m<<endl; for(int i=0;i<n;i++) { for(int j=0;j<m;j++) cout<<s[i][j]<<" "; cout<<endl; } cout<<endl; } }G[15]; inline miku operator * (const miku a,const miku b) { miku c; c.n=a.n;c.m=b.m; for(int i=0;i<c.n;i++) for(int j=0;j<c.m;j++) { for(int k=0;k<a.m;k++) c.s[i][j]+=a.s[i][k]*b.s[k][j]; c.s[i][j]%=mod; } return c; } inline miku quickpow(miku a,int b) { miku re; re.make(a.n); while(b) { if(b&1) re=re*a; b>>=1;a=a*a; } return re; } void work() { LL tem=K/12; miku ans; miku p; ans.make(N); p.make(N); for(int i=1;i<=12;i++) { ans=ans*G[i]; if(i==K%12) p=ans; } ans=quickpow(ans,tem)*p; //p.print(); //ans.print(); printf("%d",ans.s[S][E]); } int main() { freopen("swamp.in","r",stdin); freopen("swamp.out","w",stdout); scanf("%d%d%d%d%d",&N,&M,&S,&E,&K); int a,b; for(int i=0;i<=12;i++) G[i].n=G[i].m=N; for(int i=1;i<=M;i++) { scanf("%d%d",&a,&b); for(int j=0;j<=12;j++) G[j].s[a][b]=G[j].s[b][a]=1; } scanf("%d",&F); for(int i=1;i<=F;i++) { scanf("%d",&a); for(int j=1;j<=a;j++) { scanf("%d",&b); for(int k=0;k<12/a;k++) { int now=k*a; for(int t=0;t<N;t++) G[now+j].s[b][t]=0; } } } //for(int i=0;i<=12;i++) // G[i].print(); work(); return 0; }