結果

問題 No.92 逃走経路
ユーザー niyarinniyarin
提出日時 2016-06-21 18:06:27
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 25 ms / 5,000 ms
コード長 1,083 bytes
コンパイル時間 178 ms
コンパイル使用メモリ 22,400 KB
実行使用メモリ 9,856 KB
最終ジャッジ日時 2024-04-19 23:43:27
合計ジャッジ時間 1,241 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
9,088 KB
testcase_01 AC 0 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 10 ms
5,376 KB
testcase_06 AC 3 ms
5,376 KB
testcase_07 AC 3 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 14 ms
5,376 KB
testcase_10 AC 25 ms
9,856 KB
testcase_11 AC 25 ms
9,088 KB
testcase_12 AC 24 ms
5,376 KB
testcase_13 AC 7 ms
5,376 KB
testcase_14 AC 10 ms
5,376 KB
testcase_15 AC 15 ms
5,376 KB
testcase_16 AC 14 ms
5,760 KB
testcase_17 AC 21 ms
9,088 KB
testcase_18 AC 11 ms
6,400 KB
testcase_19 AC 5 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:28:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   28 |     scanf("%d %d %d",&N,&M,&K);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~
main.c:31:19: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   31 |         int a,b,c;scanf("%d %d %d",&a,&b,&c);
      |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~
main.c:39:22: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   39 |     for (i=0;i<K;i++)scanf("%d",&D[i]);
      |                      ^~~~~~~~~~~~~~~~~

ソースコード

diff #

#include<stdio.h>

int N,M,K;

int p[1001][100]={0};
int F[100][100][1000] = {0};
int fsz[100][100] = {0};
int D[1000] = {0};




void nyrn(int index,int n){
    int i,j,k;
    if (index == K+1)return;
    if (p[index][n])return;
    p[index][n] = 1;
        for (j=0;j<N;j++){
            for (k=0;k<fsz[n][j];k++){
                if (F[n][j][k] == D[index]){
                    nyrn(index+1,j);
                }
            }
        }
}

int main(void){
    scanf("%d %d %d",&N,&M,&K);
    int i=0;
    for (i=0;i<M;i++){
        int a,b,c;scanf("%d %d %d",&a,&b,&c);
        a--;
        b--;
        F[a][b][fsz[a][b]] = c;
        F[b][a][fsz[b][a]] = c;
        fsz[a][b]++;
        fsz[b][a]++;
    }
    for (i=0;i<K;i++)scanf("%d",&D[i]);

    for (i=0;i<N;i++)nyrn(0,i);
    int anss=0,ans[100]={0};
    for (i=0;i<N;i++){
        if (p[K][i]){
            ans[anss] = i;
            anss++;
        }
    }
    printf("%d\n",anss);
    for (i=0;i<anss;i++){
        printf("%d",ans[i]+1);
        if (i!=anss-1)printf(" ");
    }
    printf("\n");
    return 0;
}




0