結果
問題 | No.1602 With Animals into Institute 2 |
ユーザー |
👑 |
提出日時 | 2021-06-06 16:00:56 |
言語 | C (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,320 bytes |
コンパイル時間 | 137 ms |
コンパイル使用メモリ | 31,232 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-02 02:02:26 |
合計ジャッジ時間 | 2,177 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 12 WA * 24 |
コンパイルメッセージ
main.c: In function 'main': main.c:61:38: warning: passing argument 4 of 'DFS' from incompatible pointer type [-Wincompatible-pointer-types] 61 | ans = DFS(adj, u, N, flag, 0); | ^~~~ | | | long long int * main.c:15:46: note: expected 'int *' but argument is of type 'long long int *' 15 | long long DFS(list* adj[], int u, int t, int flag[], int label) | ~~~~^~~~~~
ソースコード
#include <stdio.h>typedef struct List {struct List *next;int v, id, cost, x;} list;const long long sup = 1LL << 60;void chmin(long long* a, long long b){if (*a > b) *a = b;}long long DFS(list* adj[], int u, int t, int flag[], int label){if (u == t) {if (label == 0) return sup;else return 0;} else flag[u] = 1;int w;long long ans = sup;list *p;for (p = adj[u]; p != NULL; p = p->next) {w = p->v;if (flag[w] != 0) continue;chmin(&ans, DFS(adj, w, t, flag, label ^ p->x) + p->cost);}flag[u] = 0;return ans;}int main(){int i, k, N, M, K, u, w, c, x, bit[31];char X[31];list *adj[51] = {}, e[1001];scanf("%d %d %d", &N, &M, &K);if (N > 50 || M > 500) return 0;for (k = 1, bit[0] = 1; k < K; k++) bit[k] = bit[k-1] << 1;for (i = 0; i < M; i++) {scanf("%d %d %d %s", &u, &w, &c, X);for (k = 0, x = 0; k < K; k++) if (X[k] == '1') x |= bit[k];e[i*2].v = w;e[i*2+1].v = u;e[i*2].id = i;e[i*2+1].id = i;e[i*2].cost = c;e[i*2+1].cost = c;e[i*2].x = x;e[i*2+1].x = x;e[i*2].next = adj[u];e[i*2+1].next = adj[w];adj[u] = &(e[i*2]);adj[w] = &(e[i*2+1]);}long long ans, flag[51];for (u = 1; u < N; u++) {ans = DFS(adj, u, N, flag, 0);printf("%lld\n", (ans == sup)? -1: ans);}fflush(stdout);return 0;}