結果
問題 | No.1480 Many Complete Graphs |
ユーザー | 👑 ygussany |
提出日時 | 2021-03-21 10:11:27 |
言語 | C (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 89 ms / 2,000 ms |
コード長 | 2,537 bytes |
コンパイル時間 | 575 ms |
コンパイル使用メモリ | 31,104 KB |
実行使用メモリ | 17,408 KB |
最終ジャッジ日時 | 2024-07-03 04:04:20 |
合計ジャッジ時間 | 4,796 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 4 ms
5,632 KB |
testcase_01 | AC | 4 ms
5,632 KB |
testcase_02 | AC | 4 ms
5,760 KB |
testcase_03 | AC | 4 ms
5,760 KB |
testcase_04 | AC | 4 ms
5,760 KB |
testcase_05 | AC | 4 ms
5,760 KB |
testcase_06 | AC | 3 ms
5,760 KB |
testcase_07 | AC | 4 ms
5,760 KB |
testcase_08 | AC | 4 ms
5,760 KB |
testcase_09 | AC | 4 ms
5,760 KB |
testcase_10 | AC | 5 ms
6,016 KB |
testcase_11 | AC | 4 ms
5,888 KB |
testcase_12 | AC | 5 ms
5,888 KB |
testcase_13 | AC | 12 ms
9,728 KB |
testcase_14 | AC | 10 ms
8,704 KB |
testcase_15 | AC | 24 ms
10,624 KB |
testcase_16 | AC | 15 ms
8,576 KB |
testcase_17 | AC | 14 ms
8,704 KB |
testcase_18 | AC | 6 ms
6,656 KB |
testcase_19 | AC | 15 ms
8,832 KB |
testcase_20 | AC | 23 ms
10,624 KB |
testcase_21 | AC | 14 ms
10,496 KB |
testcase_22 | AC | 9 ms
8,448 KB |
testcase_23 | AC | 25 ms
15,744 KB |
testcase_24 | AC | 39 ms
15,488 KB |
testcase_25 | AC | 48 ms
16,000 KB |
testcase_26 | AC | 53 ms
16,128 KB |
testcase_27 | AC | 44 ms
15,488 KB |
testcase_28 | AC | 44 ms
16,768 KB |
testcase_29 | AC | 43 ms
17,024 KB |
testcase_30 | AC | 42 ms
16,640 KB |
testcase_31 | AC | 42 ms
16,640 KB |
testcase_32 | AC | 44 ms
17,024 KB |
testcase_33 | AC | 43 ms
16,640 KB |
testcase_34 | AC | 44 ms
17,024 KB |
testcase_35 | AC | 41 ms
16,640 KB |
testcase_36 | AC | 42 ms
16,640 KB |
testcase_37 | AC | 41 ms
16,640 KB |
testcase_38 | AC | 42 ms
16,640 KB |
testcase_39 | AC | 42 ms
16,640 KB |
testcase_40 | AC | 43 ms
16,640 KB |
testcase_41 | AC | 41 ms
16,640 KB |
testcase_42 | AC | 43 ms
16,896 KB |
testcase_43 | AC | 42 ms
16,768 KB |
testcase_44 | AC | 42 ms
16,512 KB |
testcase_45 | AC | 45 ms
17,024 KB |
testcase_46 | AC | 43 ms
16,512 KB |
testcase_47 | AC | 89 ms
17,280 KB |
testcase_48 | AC | 87 ms
17,152 KB |
testcase_49 | AC | 87 ms
17,280 KB |
testcase_50 | AC | 33 ms
16,768 KB |
testcase_51 | AC | 85 ms
17,280 KB |
testcase_52 | AC | 65 ms
17,152 KB |
testcase_53 | AC | 66 ms
17,280 KB |
testcase_54 | AC | 66 ms
17,280 KB |
testcase_55 | AC | 69 ms
17,152 KB |
testcase_56 | AC | 66 ms
17,024 KB |
testcase_57 | AC | 35 ms
17,024 KB |
testcase_58 | AC | 47 ms
17,408 KB |
evil_aftercontest.txt | RE | - |
ソースコード
#include <stdio.h> typedef struct List { struct List *next; int v; long long cost; } list; typedef struct { long long key; int id; } data; typedef struct { data obj[400001]; int size; } min_heap; void push(data x, min_heap* h) { int i = ++(h->size), j = i >> 1; data tmp; h->obj[i] = x; while (j > 0) { if (h->obj[i].key < h->obj[j].key) { tmp = h->obj[j]; h->obj[j] = h->obj[i]; h->obj[i] = tmp; i = j; j >>= 1; } else break; } } data pop(min_heap* h) { int i = 1, j = 2; data output = h->obj[1], tmp; h->obj[1] = h->obj[(h->size)--]; while (j <= h->size) { if (j < h->size && h->obj[j^1].key < h->obj[j].key) j ^= 1; if (h->obj[j].key < h->obj[i].key) { tmp = h->obj[j]; h->obj[j] = h->obj[i]; h->obj[i] = tmp; i = j; j = i << 1; } else break; } return output; } int main() { int i, j, k, m, n, u, w, N, M; long long c; list *adj[500001] = {}, e[400001], *p; scanf("%d %d", &N, &M); for (i = 1, m = 0, n = N; i <= M; i++, n += 4) { scanf("%d %lld", &k, &c); for (j = 1; j <= k; j++) { scanf("%d", &u); if (u % 2 == 0) { w = n + 1; e[m].v = w; e[m].cost = c + u / 2; e[m].next = adj[u]; adj[u] = &(e[m++]); w = n + 2; e[m].v = w; e[m].cost = c + u / 2; e[m].next = adj[u]; adj[u] = &(e[m++]); w = n + 1; e[m].v = u; e[m].cost = u / 2; e[m].next = adj[w]; adj[w] = &(e[m++]); w = n + 3; e[m].v = u; e[m].cost = u / 2; e[m].next = adj[w]; adj[w] = &(e[m++]); } else { w = n + 3; e[m].v = w; e[m].cost = c + u / 2 + 1; e[m].next = adj[u]; adj[u] = &(e[m++]); w = n + 4; e[m].v = w; e[m].cost = c + u / 2 + 1; e[m].next = adj[u]; adj[u] = &(e[m++]); w = n + 2; e[m].v = u; e[m].cost = u / 2 + 1; e[m].next = adj[w]; adj[w] = &(e[m++]); w = n + 4; e[m].v = u; e[m].cost = u / 2; e[m].next = adj[w]; adj[w] = &(e[m++]); } } } const long long sup = 1LL << 60; long long dist[500001]; min_heap h; data d; for (u = 1; u <= n; u++) dist[u] = sup; dist[1] = 0; h.size = 0; d.key = 0; d.id = 1; push(d, &h); while (h.size > 0) { d = pop(&h); u = d.id; if (d.key != dist[u]) continue; for (p = adj[u]; p != NULL; p = p->next) { w = p->v; if (dist[w] > dist[u] + p->cost) { dist[w] = dist[u] + p->cost; d.key = dist[w]; d.id = w; push(d, &h); } } } if (dist[N] == sup) printf("-1\n"); else printf("%lld\n", dist[N]); fflush(stdout); return 0; }