QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#658595#9488. Do Not Turn Backucup-team5318#RE 0ms0kbC++141.0kb2024-10-19 17:06:592024-10-19 17:07:01

Judging History

你现在查看的是最新测评结果

  • [2024-10-19 17:07:01]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-10-19 17:06:59]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=205,mod=998244353;
int n,m,k,d[N];
vector<int>e[N];
struct Mat{
	ll a[N][N];
	Mat(int p=0){memset(a,0,sizeof(a));if(p)for(int i=1;i<=n*2;i++)a[i][i]=1;}
	friend Mat operator*(const Mat&x,const Mat&y) {
		Mat z;
		for(int i=1;i<=n*2;i++)for(int j=1;j<=n*2;j++)for(int k=1;k<=n*2;k++)	
			z.a[i][j]=(z.a[i][j]+x.a[i][k]*y.a[k][j])%mod;
		return z;
	}
};
Mat qp(Mat a,int b){Mat ans(1);for(;b;b>>=1,a=a*a)if(b&1)ans=ans*a;return ans;}
int main() {
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin>>n>>m>>k;
	for(int i=1,x,y;i<=m;i++)cin>>x>>y,e[x].push_back(y),e[y].push_back(x),d[x]++,d[y]++;
	Mat st,F;
	for(int i=1;i<=n;i++) {
		for(int j:e[i])st.a[i][j]=1;
		st.a[i][i+n]=1,st.a[i+n][i]=-d[i];
	}
	if(k<=2) {
		F=qp(st,k);
	}else {
		F=qp(st,2);
		for(int i=1;i<=n;i++)st.a[i+n][i]++;
		F=F*qp(st,k-2);
	}
	cout<<(F.a[1][n]+mod)%mod<<'\n';
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Dangerous Syscalls

input:

6 8 5
1 2
1 3
2 3
2 4
3 5
4 5
4 6
5 6

output:


result: