E - King Bombee 链接 #include<iostream> #include<vector> using namespace std; #define pb push_back typedef long long LL; const int N=2100,p=998244353; vector<int>e[N]; LL f[N][N][3]; int n,m,k,s,t,x; int main() { cin>>n>>m>>k>>s>>t>>x; while(m--) { int a,b; cin>>a>>b; e[a].pb(b); e[b].pb(a); } f[0][s][0]=1; for(int i=1;i<=k;i++) //i:从起点走i步 for(int j=1;j<=n;j++) { for(auto last:e[j]) { if(j==x) { f[i][j][0]=(f[i][j][0]+f[i-1][last][1])%p; f[i][j][1]=(f[i][j][1]+f[i-1][last][0])%p; }else { f[i][j][0]=(f[i][j][0]+f[i-1][last][0])%p; f[i][j][1]=(f[i][j][1]+f[i-1][last][1])%p; } } } cout<<f[k][t][0]<<endl; return 0; }