Submission #537879

#TimeUsernameProblemLanguageResultExecution timeMemory
537879__VariattoPaths (BOI18_paths)C++17
53 / 100
148 ms30592 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back #define fi first #define se second #define ll long long const int MAX=1e5+10, K=1<<5; ll n, m, k, dp[K+2][MAX], kol[MAX]; vector<int>g[MAX]; int main(){ ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0); cin>>n>>m>>k; for(int i=1; i<=n; i++) cin>>kol[i]; for(int i=1; i<=m; i++){ int a,b; cin>>a>>b; g[a].pb(b), g[b].pb(a); } ll wyn=0; for(int i=1; i<(1<<k); i++){ for(int v=1; v<=n; v++){ if(!(i&(1<<(kol[v]-1)))) continue; if(__builtin_popcount(i)==1) dp[i][v]=1; //cout<<i<<" "<<kol[v]<<"\n"; for(auto s:g[v]) dp[i][v]+=dp[i-(1<<(kol[v]-1))][s]; if(__builtin_popcount(i)>1) wyn+=dp[i][v]; } } cout<<wyn<<"\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...