-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathabc244_e.cpp
More file actions
33 lines (31 loc) · 843 Bytes
/
abc244_e.cpp
File metadata and controls
33 lines (31 loc) · 843 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <iostream>
#include <vector>
typedef long long ll;
using namespace std;
const ll MAX = 998244353;
vector<pair<int,int>> edges;
int N, M, K, S, T, X;
void solve(){
cin >> N >> M >> K >> S >> T >> X;
for (int i = 0; i < M; i++){
int a, b;
cin >> a >> b;
edges.push_back({a, b});
}
ll dp[2002][2002][2]; for (int i = 0; i <=N; i++) for (int j = 0; j <=N; j++) for (int k = 0; k < 2; k++) dp[i][j][k] = 0;
dp[0][S][0] = 1;
for (int i = 0; i < K; i++) {
for (auto [u,v] : edges) {
for (int k = 0; k < 2; k++) {
dp[i+1][v][k ^ (v == X)] = (dp[i][u][k] + dp[i+1][v][k ^ (v == X)]) % MAX;
dp[i+1][u][k ^ (u == X)] = (dp[i][v][k] + dp[i+1][u][k ^ (u == X)]) % MAX;
}
}
}
cout << dp[K][T][0];
}
int main(){
cout.tie(0);cin.tie(0)->sync_with_stdio(0);
solve();
return 0;
}