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;
typedef long double ld;
#define int long long
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const int LIM=3e5+7;
vector<int>V[LIM];
int T[LIM], dp[LIM][1<<5];
int32_t main() {
ios_base::sync_with_stdio(0); cin.tie(0);
int n, m, k;
cin >> n >> m >> k;
rep(i, n) {
cin >> T[i]; --T[i];
dp[i][1<<T[i]]=1;
}
rep(i, m) {
int a, b;
cin >> a >> b; --a; --b;
V[a].pb(b);
V[b].pb(a);
}
int ans=0;
for(int i=1; i<(1<<k); ++i) {
rep(j, n) {
if(__builtin_popcount(i)>1) ans+=dp[j][i];
for(auto l : V[j]) if(!(i&(1<<T[l]))) {
dp[l][i+(1<<T[l])]+=dp[j][i];
}
}
}
cout << ans << '\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... |