# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
870656 |
2023-11-08T17:44:06 Z |
TheSahib |
Paths (BOI18_paths) |
C++14 |
|
0 ms |
0 KB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define oo 1e18
const int MAX = 3e5 + 5;
vector<int> g[MAX];
ll dp[33][MAX];
int c[MAX];
int n, m, k;
ll rec(int node, int mask){
mask |= (1 << c[node]);
if(dp[mask][node] != -1) return dp[mask][node];
ll ans = 0;
if(__popcount(mask) >= 2) ans++;
for(int to : g[node]){
if(mask & (1 << c[to])){
continue;
}
ans += rec(to, mask);
}
return dp[mask][node] = ans;
}
int main(){
memset(dp, -1, sizeof(dp));
cin >> n >> m >> k;
for(int i = 1; i <= n; i++){
cin >> c[i];
c[i]--;
}
for(int i = 1; i <= m; i++){
int a, b; cin >> a >> b;
g[a].push_back(b);
g[b].push_back(a);
}
ll ans = 0;
for(int i = 1; i <= n; i++){
ans += rec(i, 0);
}
cout << ans << '\n';
}
Compilation message
paths.cpp: In function 'long long int rec(int, int)':
paths.cpp:22:8: error: '__popcount' was not declared in this scope
22 | if(__popcount(mask) >= 2) ans++;
| ^~~~~~~~~~