結果
問題 | No.807 umg tours |
ユーザー | bal4u |
提出日時 | 2019-07-10 06:42:10 |
言語 | C (gcc 12.3.0) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,885 bytes |
コンパイル時間 | 970 ms |
コンパイル使用メモリ | 30,464 KB |
実行使用メモリ | 21,140 KB |
最終ジャッジ日時 | 2023-08-15 12:27:38 |
合計ジャッジ時間 | 8,405 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
10,124 KB |
testcase_01 | AC | 1 ms
5,824 KB |
testcase_02 | AC | 1 ms
5,776 KB |
testcase_03 | AC | 1 ms
5,760 KB |
testcase_04 | AC | 1 ms
5,716 KB |
testcase_05 | AC | 1 ms
5,828 KB |
testcase_06 | AC | 1 ms
5,712 KB |
testcase_07 | AC | 1 ms
5,712 KB |
testcase_08 | AC | 2 ms
5,784 KB |
testcase_09 | AC | 1 ms
5,704 KB |
testcase_10 | AC | 1 ms
5,712 KB |
testcase_11 | AC | 41 ms
12,332 KB |
testcase_12 | AC | 31 ms
13,136 KB |
testcase_13 | AC | 43 ms
14,476 KB |
testcase_14 | AC | 18 ms
9,828 KB |
testcase_15 | AC | 14 ms
9,368 KB |
testcase_16 | AC | 46 ms
14,980 KB |
testcase_17 | AC | 57 ms
17,392 KB |
testcase_18 | AC | 67 ms
17,944 KB |
testcase_19 | AC | 61 ms
17,400 KB |
testcase_20 | AC | 30 ms
14,216 KB |
testcase_21 | AC | 30 ms
14,616 KB |
testcase_22 | AC | 13 ms
9,444 KB |
testcase_23 | AC | 10 ms
8,700 KB |
testcase_24 | TLE | - |
testcase_25 | -- | - |
コンパイルメッセージ
main.c: 関数 ‘in’ 内: main.c:11:14: 警告: 関数 ‘getchar_unlocked’ の暗黙的な宣言です [-Wimplicit-function-declaration] 11 | #define gc() getchar_unlocked() | ^~~~~~~~~~~~~~~~ main.c:19:24: 備考: in expansion of macro ‘gc’ 19 | int n = 0, c = gc(); | ^~ main.c: 関数 ‘out’ 内: main.c:12:15: 警告: 関数 ‘putchar_unlocked’ の暗黙的な宣言です [-Wimplicit-function-declaration] 12 | #define pc(c) putchar_unlocked(c) | ^~~~~~~~~~~~~~~~ main.c:29:21: 備考: in expansion of macro ‘pc’ 29 | while (i--) pc(b[i]); | ^~
ソースコード
// yukicoder: No.807 umg tours // 2019.7.10 bal4u #include <stdio.h> #include <stdlib.h> #include <string.h> typedef long long ll; #if 1 #define gc() getchar_unlocked() #define pc(c) putchar_unlocked(c) #else #define gc() getchar() #define pc(c) putchar(c) #endif int in() { // 非負整数の入力 int n = 0, c = gc(); do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0'); return n; } void out(long n) { // 正整数の表示(出力) int i; char b[20]; i = 0; while (n) b[i++] = n % 10 + '0', n /= 10; while (i--) pc(b[i]); pc('\n'); } #define INF 0x33 #define QMAX 1000005 #define MAX 100005 int *to[MAX], *dis[MAX], hi[MAX]; int N; ll ma[MAX], mi[MAX]; int q[QMAX], top, end; // queue void bfs() { int i, a, b, f; memset(mi, INF, sizeof(ll)*N); memset(ma, INF, sizeof(ll)*N); for (i = 0; i < hi[0]; i++) { b = to[0][i]; q[end++] = b, ma[b] = dis[0][i], mi[b] = 0; } while (top != end) { a = q[top++]; // printf("a=%d, ma=%lld, mi=%lld\n", a, ma[a], mi[a]); for (i = 0; i < hi[a]; i++) { b = to[a][i], f = 0; if (ma[b] > dis[a][i]+ma[a]) ma[b] = ma[a] + dis[a][i], f = 1; if (mi[b] > dis[a][i]+mi[a]) mi[b] = mi[a] + dis[a][i], f = 1; if (mi[b] > ma[a]) mi[b] = ma[a], f = 1; if (f) q[end++] = b; } } } int main() { int i, k, a, b, c, M; int *memo, sz; N = in(), M = in(); memo = malloc(sizeof(int)*M*3); sz = 0; while (M--) { memo[sz++] = a = in()-1, memo[sz++] = b = in()-1, memo[sz++] = in(); hi[a]++, hi[b]++; } for (i = 0; i < N; i++) if (hi[i]) { to[i] = malloc(sizeof(int)*hi[i]); dis[i] = malloc(sizeof(int)*hi[i]); } memset(hi, 0, sizeof(hi)); i = 0; while (i < sz) { a = memo[i++], b = memo[i++], c = memo[i++]; k = hi[a]++, to[a][k] = b, dis[a][k] = c; k = hi[b]++, to[b][k] = a, dis[b][k] = c; } bfs(); pc('0'), pc('\n'); for (i = 1; i < N; i++) out(ma[i] + mi[i]); return 0; }