# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
95453 | 2019-02-01T09:38:35 Z | bacegen4o | Paths (BOI18_paths) | C | 219 ms | 19704 KB |
#include<stdio.h> #include<stdlib.h> #include<string.h> #include<math.h> #include<assert.h> #include<stdbool.h> #include<limits.h> typedef long long ll; #define resizeArray(ptr, type, size) ((type*)realloc(ptr, (size) * sizeof(type))) int *pushback(int *array, int *size, int value) { int *output = resizeArray(array, int, *size + 1); output[(*size)++] = value; return output; } typedef struct{ int*ptr; int sz; }vec; vec newVec() { vec rez; rez.ptr = NULL; rez.sz = 0; return rez; } //////////////---------------- baltic paths int main() { int n, m, k, a, b; scanf("%d %d %d", &n, &m, &k); int colors[n]; vec graph [n]; memset(graph, 0, sizeof(graph)); for(int c1=0; c1<n; c1++){ scanf("%d", &colors[c1]); colors[c1]--; } for(int c1 = 0; c1 < m; c1++){ scanf("%d %d", &a, &b); a--, b--; graph[a].ptr = pushback(graph[a].ptr, &graph[a].sz, b); graph[b].ptr = pushback(graph[b].ptr, &graph[b].sz, a); } ll ans = 0; for(int c1=0; c1<n; c1++){ ll F[3] = {0}; for(int c2 = 0; c2 < graph[c1].sz; c2++) F[colors[graph[c1].ptr[c2]]]++; F[colors[c1]] = 0; ans += 2*(F[0]*F[1]+F[0]*F[2]+F[1]*F[2])+F[0]+F[1]+F[2]; } printf("%lld\n", ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 2 ms | 376 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 109 ms | 5880 KB | Output is correct |
2 | Correct | 103 ms | 5496 KB | Output is correct |
3 | Correct | 206 ms | 18908 KB | Output is correct |
4 | Correct | 110 ms | 7544 KB | Output is correct |
5 | Correct | 106 ms | 7644 KB | Output is correct |
6 | Correct | 151 ms | 15352 KB | Output is correct |
7 | Correct | 207 ms | 18812 KB | Output is correct |
8 | Correct | 219 ms | 19704 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 2 ms | 376 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 380 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |