Submission #887670

#TimeUsernameProblemLanguageResultExecution timeMemory
887670votranngocvyPaths (BOI18_paths)C++14
23 / 100
3053 ms11172 KiB
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 5; int n,m,k,ans,a[N]; bool vis[10]; vector<int>g[N]; void dfs(int u) { vis[a[u]] = true; for (auto v: g[u]) { if (vis[a[v]]) continue; ans++; dfs(v); } vis[a[u]] = false; } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m >> k; for (int i = 1; i <= n; i++) { cin >> a[i]; a[i]--; } for (int i = 1; i <= m; i++) { int u,v; cin >> u >> v; g[u].push_back(v); g[v].push_back(u); } for (int i = 1; i <= n; i++) dfs(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...