Submission #864334

#TimeUsernameProblemLanguageResultExecution timeMemory
864334maks007Paths (BOI18_paths)C++14
20 / 100
268 ms28368 KiB
#include "bits/stdc++.h" using namespace std; #define int long long vector <int> color; vector <vector <int>> cntColor; signed main () { int n, m, k; cin >> n >> m >> k; color.resize(n); cntColor.resize(n, vector <int> (k + 1, 0)); for(int i = 0; i < n; i ++) cin >> color[i]; for(int i = 0, u, v; i < m; i ++) { cin >> u >> v; u --, v --; cntColor[u][color[v]] ++; cntColor[v][color[u]] ++; } int ans = 0; for(int color2 = 1; color2 <= k; color2 ++) { for(int i = 0; i < n; i ++) { if(color[i] == color2) { for(int color1 = 1; color1 <= k; color1 ++) { if(color1 == color2) continue; ans += cntColor[i][color1]; if(k == 2) continue; for(int color3 = color1 + 1; color3 <= k; color3 ++) { if(color3 == color2) continue; ans += 2 * (cntColor[i][color1] * cntColor[i][color3]); } } } } } 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...