Submission #881085

#TimeUsernameProblemLanguageResultExecution timeMemory
881085OAleksaPaths (BOI18_paths)C++14
23 / 100
3038 ms12624 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define f first #define s second const int maxn = 1e5 + 69; int n, m, k, a[maxn], ans; vector<int> g[maxn]; void dfs(int v, int nmask) { ans += (nmask == 0); for (auto u : g[v]) { if (nmask & (1 << a[u])) dfs(u, nmask ^ (1 << a[u])); } } signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int tt = 1; //cin >> tt; while (tt--) { cin >> n >> m >> k; for (int i = 1;i <= n;i++) { cin >> a[i]; --a[i]; } for (int i = 1;i <= m;i++) { int a, b; cin >> a >> b; g[a].push_back(b); g[b].push_back(a); } for (int mask = 1;mask < (1 << k);mask++) { for (int i = 1;i <= n;i++) { if (mask & (1 << a[i])) dfs(i, mask ^ (1 << a[i])); } } ans -= n; cout << ans; } 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...