This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
long long dp[32][300005], a[300005];
vector<long long> adj[300005];
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long n, m, p, ans=0;
cin >> n >> m >> p;
for (long long i=1; i<=n; i++)
{
cin >> a[i];
dp[1<<(--a[i])][i]=1;
}
for (long long i=1; i<=m; i++)
{
long long u, v;
cin >> u >> v;
adj[u].push_back(v);
adj[v].push_back(u);
}
for (long long i=1; i<(1<<p); i++)
{
for (long long j=1; j<=n; j++)
{
if (i&(1<<a[j]))
for (long long k:adj[j])
dp[i][j]+=dp[i^(1<<a[j])][k];
ans+=dp[i][j];
}
}
cout << ans-n;
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... |