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 long ll;
typedef long double ld;
ll dp[300005][32];
vector <int> graf[300005];
int col[300005];
int main(){
ios_base::sync_with_stdio(false);
cout.precision(10);
cout<<fixed;
int n, m, k;
cin >> n >> m >> k;
for(int i=1; i<=n; i++){
cin >> col[i];
col[i]--;
dp[i][(1<<col[i])] = 1;
}
for(int i=1; i<=m; i++){
int a, b;
cin >> a >> b;
graf[a].push_back(b);
graf[b].push_back(a);
}
ll res = -n;
for(int j=0; j<(1<<k); j++){
for(int i=1; i<=n; i++){
if(!((1<<col[i]) & j)){
continue;
}
for(auto c : graf[i]){
dp[i][j] += dp[c][j - (1<<col[i])];
}
res += dp[i][j];
}
}
cout << res << "\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... |