# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
864342 | 2023-10-22T14:40:11 Z | maks007 | Paths (BOI18_paths) | C++14 | 456 ms | 46420 KB |
#include "bits/stdc++.h" using namespace std; #define int long long vector <int> color; vector <vector <int>> cntColor, g; signed main () { int n, m, k; cin >> n >> m >> k; color.resize(n); cntColor.resize(n, vector <int> (k + 1, 0)); g.resize(n); for(int i = 0; i < n; i ++) cin >> color[i]; for(int i = 0, u, v; i < m; i ++) { cin >> u >> v; u --, v --; g[u].push_back(v); g[v].push_back(u); 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 << " "; if(k >= 4) { for(int v = 0; v < n; v ++) { for(auto u : g[v]) { if(color[u] == color[v]) continue; int cnt1 = 0, cnt2 = 0; for(int i = 1; i <= k; i ++) { if(i == color[u] || color[v] == i) continue; for(int j = 1; j <= k; j ++) { if(j == i || j == color[u] || j == color[v]) continue; ans += cntColor[v][i] * cntColor[u][j]; } } } } } cout << ans; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 432 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 344 KB | Output is correct |
6 | Correct | 0 ms | 344 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 111 ms | 8020 KB | Output is correct |
2 | Correct | 109 ms | 7400 KB | Output is correct |
3 | Correct | 374 ms | 41516 KB | Output is correct |
4 | Correct | 138 ms | 11092 KB | Output is correct |
5 | Correct | 136 ms | 11092 KB | Output is correct |
6 | Correct | 262 ms | 29628 KB | Output is correct |
7 | Correct | 359 ms | 41332 KB | Output is correct |
8 | Correct | 337 ms | 42064 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 432 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 344 KB | Output is correct |
6 | Correct | 0 ms | 344 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 111 ms | 8020 KB | Output is correct |
12 | Correct | 109 ms | 7400 KB | Output is correct |
13 | Correct | 374 ms | 41516 KB | Output is correct |
14 | Correct | 138 ms | 11092 KB | Output is correct |
15 | Correct | 136 ms | 11092 KB | Output is correct |
16 | Correct | 262 ms | 29628 KB | Output is correct |
17 | Correct | 359 ms | 41332 KB | Output is correct |
18 | Correct | 337 ms | 42064 KB | Output is correct |
19 | Correct | 111 ms | 10836 KB | Output is correct |
20 | Correct | 87 ms | 9792 KB | Output is correct |
21 | Correct | 362 ms | 45980 KB | Output is correct |
22 | Correct | 143 ms | 14420 KB | Output is correct |
23 | Correct | 140 ms | 14400 KB | Output is correct |
24 | Correct | 265 ms | 33548 KB | Output is correct |
25 | Correct | 324 ms | 45752 KB | Output is correct |
26 | Correct | 327 ms | 46420 KB | Output is correct |
27 | Correct | 101 ms | 9812 KB | Output is correct |
28 | Correct | 157 ms | 12560 KB | Output is correct |
29 | Correct | 456 ms | 46156 KB | Output is correct |
30 | Correct | 285 ms | 28272 KB | Output is correct |
31 | Correct | 304 ms | 28612 KB | Output is correct |
32 | Correct | 401 ms | 45804 KB | Output is correct |
33 | Correct | 0 ms | 344 KB | Output is correct |
34 | Correct | 0 ms | 348 KB | Output is correct |
35 | Correct | 0 ms | 348 KB | Output is correct |
36 | Correct | 0 ms | 348 KB | Output is correct |
37 | Correct | 0 ms | 344 KB | Output is correct |
38 | Correct | 0 ms | 344 KB | Output is correct |
39 | Correct | 0 ms | 344 KB | Output is correct |
40 | Correct | 0 ms | 348 KB | Output is correct |
41 | Correct | 0 ms | 348 KB | Output is correct |
42 | Correct | 0 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Incorrect | 35 ms | 2652 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |