Submission #624975

#TimeUsernameProblemLanguageResultExecution timeMemory
624975HanksburgerPaths (BOI18_paths)C++17
100 / 100
329 ms59960 KiB
#include <bits/stdc++.h> using namespace std; long long dp[32][300005], a[300005]; vector<long long> adj[300005]; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n, m, p, ans=0; cin >> n >> m >> p; for (long long i=1; i<=n; i++) { cin >> a[i]; dp[1<<(--a[i])][i]=1; } for (long long i=1; i<=m; i++) { long long u, v; cin >> u >> v; adj[u].push_back(v); adj[v].push_back(u); } for (long long i=1; i<(1<<p); i++) { for (long long j=1; j<=n; j++) { if (i&(1<<a[j])) for (long long k:adj[j]) dp[i][j]+=dp[i^(1<<a[j])][k]; ans+=dp[i][j]; } } cout << ans-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...