#include "bits/stdc++.h"
using namespace std;
#ifdef duc_debug
#include "bits/debug.h"
#else
#define debug(...)
#endif
const int maxn = 1e5 + 5;
int n, m, k;
int a[maxn];
vector<int> g[maxn];
long long f[maxn][35];
void solve() {
cin >> n >> m >> k;
for (int i = 1; i <= n; ++i) {
cin >> a[i];
--a[i];
f[i][1 << a[i]] = 1;
}
for (int i = 1; i <= m; ++i) {
int u, v; cin >> u >> v;
g[u].push_back(v);
g[v].push_back(u);
}
long long tot = 0;
for (int mask = 0; mask < (1 << k); ++mask) {
for (int u = 1; u <= n; ++u) {
for (auto v : g[u]) {
if (mask >> a[v] & 1) {
continue;
}
f[v][mask ^ (1 << a[v])] += f[u][mask];
}
if (__builtin_popcount(mask) > 1) tot += f[u][mask];
}
}
cout << tot;
}
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
solve();
return 0;
}
# | 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... |