Submission #476413

#TimeUsernameProblemLanguageResultExecution timeMemory
476413AdamGSPaths (BOI18_paths)C++14
53 / 100
383 ms57920 KiB
#include<bits/stdc++.h> using namespace std; typedef long double ld; #define int long long #define rep(a, b) for(int a = 0; a < (b); ++a) #define st first #define nd second #define pb push_back #define all(a) a.begin(), a.end() const int LIM=1e5+7; vector<int>V[LIM]; int T[LIM], dp[LIM][1<<5]; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, m, k; cin >> n >> m >> k; rep(i, n) { cin >> T[i]; --T[i]; dp[i][1<<T[i]]=1; } rep(i, m) { int a, b; cin >> a >> b; --a; --b; V[a].pb(b); V[b].pb(a); } int ans=0; for(int i=1; i<(1<<k); ++i) { rep(j, n) { if(__builtin_popcount(i)>1) ans+=dp[j][i]; for(auto l : V[j]) if(!(i&(1<<T[l]))) { dp[l][i+(1<<T[l])]+=dp[j][i]; } } } 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...