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;
#define pb push_back
#define fi first
#define se second
#define ll long long
const int MAX=1e5+10, K=1<<5;
ll n, m, k, dp[K+2][MAX], kol[MAX];
vector<int>g[MAX];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
cin>>n>>m>>k;
for(int i=1; i<=n; i++)
cin>>kol[i];
for(int i=1; i<=m; i++){
int a,b;
cin>>a>>b;
g[a].pb(b), g[b].pb(a);
}
ll wyn=0;
for(int i=1; i<(1<<k); i++){
for(int v=1; v<=n; v++){
if(!(i&(1<<(kol[v]-1)))) continue;
if(__builtin_popcount(i)==1)
dp[i][v]=1;
//cout<<i<<" "<<kol[v]<<"\n";
for(auto s:g[v])
dp[i][v]+=dp[i-(1<<(kol[v]-1))][s];
if(__builtin_popcount(i)>1)
wyn+=dp[i][v];
}
}
cout<<wyn<<"\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... |