Submission #462615

#TimeUsernameProblemLanguageResultExecution timeMemory
462615JovanBPaths (BOI18_paths)C++17
100 / 100
518 ms97168 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...