#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define pb push_back
#define ff first
#define ss second
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, m, k; cin>>n>>m>>k;
vector<int> a(n + 1);
for (int i = 1; i <= n; i++){
cin>>a[i];
a[i]--;
}
vector<int> g[n + 1];
while (m--){
int x, y; cin>>x>>y;
g[x].pb(y);
g[y].pb(x);
}
vector<vector<ll>> dp(n + 1, vector<ll>(1 << k));
ll out = 0;
for (int x = 1; x < (1 << k); x++){
for (int i = 1; i <= n; i++){
if ((1 << a[i]) & x){
int f = x - (1 << a[i]);
if (!f){
dp[i][x] = 1;
continue;
}
for (int j: g[i]){
dp[i][x] += dp[j][f];
}
out += dp[i][x];
}
}
}
cout<<out<<"\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |