Submission #642588

#TimeUsernameProblemLanguageResultExecution timeMemory
642588andreast12Paths (BOI18_paths)C++17
23 / 100
3091 ms9184 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define fi first #define se second const int mod=998244353, maxn=1e5+5; int n, m, k, c[maxn], u, v, ans; vector<int> adj[maxn]; bool vis[maxn]; void dfs(int now, int state, int jml) { if(!vis[now]&&(((1<<c[now])&state)==0)) { if(jml==1) { ans++; } else { vis[now]=true; for(auto nxt:adj[now]) { dfs(nxt, state|(1<<c[now]), jml-1); } } vis[now]=false; } } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> m >> k; for(int i=1; i<=n; i++) cin >> c[i]; while(m--) { cin >> u >> v; adj[u].pb(v); adj[v].pb(u); } for(int jml=2; jml<=k; jml++) { for(int i=1; i<=n; i++) { dfs(i, 0, jml); } } 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...