結果
問題 | No.30 たこやき工場 |
ユーザー | mudbdb |
提出日時 | 2015-07-29 20:46:37 |
言語 | C90 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 1 ms / 5,000 ms |
コード長 | 1,934 bytes |
コンパイル時間 | 956 ms |
コンパイル使用メモリ | 24,064 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-01 02:57:41 |
合計ジャッジ時間 | 1,518 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,812 KB |
testcase_01 | AC | 1 ms
6,944 KB |
testcase_02 | AC | 1 ms
6,940 KB |
testcase_03 | AC | 0 ms
6,944 KB |
testcase_04 | AC | 0 ms
6,944 KB |
testcase_05 | AC | 1 ms
6,940 KB |
testcase_06 | AC | 1 ms
6,944 KB |
testcase_07 | AC | 1 ms
6,940 KB |
testcase_08 | AC | 1 ms
6,940 KB |
testcase_09 | AC | 1 ms
6,944 KB |
testcase_10 | AC | 1 ms
6,940 KB |
testcase_11 | AC | 0 ms
6,940 KB |
testcase_12 | AC | 1 ms
6,940 KB |
testcase_13 | AC | 1 ms
6,940 KB |
testcase_14 | AC | 1 ms
6,944 KB |
testcase_15 | AC | 1 ms
6,940 KB |
testcase_16 | AC | 1 ms
6,944 KB |
コンパイルメッセージ
main.c: In function ‘main’: main.c:76:18: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long long int’ [-Wformat=] 76 | printf("%d\n", total(no, N)); | ~^ ~~~~~~~~~~~~ | | | | int long long int | %lld main.c:29:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 29 | scanf("%d", &N); | ^~~~~~~~~~~~~~~ main.c:30:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 30 | scanf("%d", &M); | ^~~~~~~~~~~~~~~ main.c:36:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 36 | scanf("%d", &(P[i])); | ^~~~~~~~~~~~~~~~~~~~ main.c:37:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 37 | scanf("%d", &(Q[i])); | ^~~~~~~~~~~~~~~~~~~~ main.c:38:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 38 | scanf("%d", &(R[i])); | ^~~~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h> #include <stdlib.h> int **E; int **V; int *I; long long int **T; long long int total(int start, int end) { int i; if (T[start][end] == -1) { if (start == end) { T[start][end] = 1; } else { T[start][end] = 0; for (i=0; i<I[end]; i++) { T[start][end] += total(start, V[end][i]) * E[V[end][i]][end]; } } } return T[start][end]; } int main() { int N; int M; int *P; int *Q; int *R; scanf("%d", &N); scanf("%d", &M); P = (int*)malloc(sizeof(int)*M); Q = (int*)malloc(sizeof(int)*M); R = (int*)malloc(sizeof(int)*M); int i; for (i=0; i<M; i++) { scanf("%d", &(P[i])); scanf("%d", &(Q[i])); scanf("%d", &(R[i])); } int no; int *R_cnt = (int*)malloc(sizeof(int)*(N+1)); for (no=0; no<=N; no++) R_cnt[no] = 0; for (i=0; i<M; i++) R_cnt[R[i]]++; int *P_cnt = (int*)malloc(sizeof(int)*(N+1)); for (no=0; no<=N; no++) P_cnt[no] = 0; for (i=0; i<M; i++) P_cnt[P[i]]++; V = (int**)malloc(sizeof(int*)*(N+1)); V[0] = (int*)malloc(sizeof(int)*(N+1)*N); for (i=1; i<=N; i++) V[i] = &(V[i-1][N]); I = (int*)malloc(sizeof(int)*(N+1)); for (i=0; i<=N; i++) I[i] = 0; for (i=0; i<M; i++) { V[R[i]][I[R[i]]] = P[i]; I[R[i]]++; } E = (int**)malloc(sizeof(int*)*(N+1)); E[0] = (int*)malloc(sizeof(int)*(N+1)*(N+1)); for (i=0; i<(N+1)*(N+1); i++) E[0][i] = 0; for (i=1; i<=N; i++) E[i] = &(E[i-1][N+1]); for (i=0; i<M; i++) E[P[i]][R[i]] = Q[i]; T = (long long int**)malloc(sizeof(long long int*)*(N+1)); T[0] = (long long int*)malloc(sizeof(long long int)*(N+1)*(N+1)); for (i=0; i<(N+1)*(N+1); i++) T[0][i] = -1; for (i=1; i<=N; i++) T[i] = &(T[i-1][N+1]); for (no=1; no<N; no++) { if (R_cnt[no] == 0) { if (P_cnt[no] == 0) { printf("%d\n", 0); } else { printf("%d\n", total(no, N)); } } else { printf("%d\n", 0); } } return 0; }