Submission #789520

#TimeUsernameProblemLanguageResultExecution timeMemory
789520Trisanu_DasPaths (BOI18_paths)C++17
0 / 100
115 ms17680 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int n, m, k, a[300005], dt[1 << 5][300005], ans, u, v; vector<int> adj[300005]; signed main(){ cin >> n >> m >> k; for(int i = 1; i < n + 1; i++) {cin >> a[i], a[i]--;} for(int i = 1; i < m + 1; i++){ cin >> u >> v; adj[u].push_back(v); adj[v].push_back(u); } for(int m = 1; m < (1 << k); m++){ for(int u = 1; u < n + 1; u++){ int j = 1 << a[u]; if(!(j & m)) continue; if(j == m) dt[m][u] = 1; for(auto v : adj[u]) dt[m][u] += dt[m - j][v]; ans += dt[m][u]; } } cout << ans << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...