結果

問題 No.340 雪の足跡
ユーザー maimai
提出日時 2016-01-30 20:09:55
言語 C90
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,044 bytes
コンパイル時間 678 ms
コンパイル使用メモリ 23,020 KB
実行使用メモリ 9,624 KB
最終ジャッジ日時 2023-10-21 18:08:32
合計ジャッジ時間 4,577 ms
ジャッジサーバーID
(参考情報)
judge12 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 0 ms
4,348 KB
testcase_02 AC 0 ms
4,348 KB
testcase_03 WA -
testcase_04 AC 0 ms
4,348 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 0 ms
4,348 KB
testcase_09 WA -
testcase_10 AC 0 ms
4,348 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 TLE -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:6:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
    6 | main(){
      | ^~~~
main.c: In function ‘main’:
main.c:68:46: warning: implicit declaration of function ‘exit’ [-Wimplicit-function-declaration]
   68 |         if (x==w-1&&y==h-1){printf("%d\n",j);exit(0);}
      |                                              ^~~~
main.c:2:1: note: include ‘<stdlib.h>’ or provide a declaration of ‘exit’
    1 | #include <stdio.h>
  +++ |+#include <stdlib.h>
    2 | 
main.c:68:46: warning: incompatible implicit declaration of built-in function ‘exit’ [-Wbuiltin-declaration-mismatch]
   68 |         if (x==w-1&&y==h-1){printf("%d\n",j);exit(0);}
      |                                              ^~~~
main.c:68:46: note: include ‘<stdlib.h>’ or provide a declaration of ‘exit’
main.c:13:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   13 |     scanf("%d%d%d",&w,&h,&n);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~
main.c:20:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   20 |         scanf("%d",&m);
      |         ^~~~~~~~~~~~~~
main.c:23:13: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   23 |             scanf("%d",&k);
      |             ^~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>

    int map[1000][1000];
    int w,h,n;

main(){
    int i,j,k,m,x,y,f,t,vx,vy,v,u,c;
    int ada[1000];
    int open[1000][2];
    int close[1000];
    int iopen=0,iclose=0;
    
    scanf("%d%d%d",&w,&h,&n);
    
    for (x=0;x<w;x++)
        for (y=0;y<h;y++)
            map[x][y]=0;
            
    for (i=0;i<n;i++){
        scanf("%d",&m);
        m++;
        for (j=0;j<m;j++){
            scanf("%d",&k);
            ada[j]=k;
        }
        for (j=1;j<m;j++){
            f=ada[j-1];
            t=ada[j];
            if (t-f>0){
                if (t-f>=w){
                    vx=0;vy=1;v=8;u=2;
                }else{
                    vx=1;vy=0;v=4;u=1;
                }
            }else{
                if (t-f<=-w){
                    vx=0;vy=-1;v=2;u=8;
                }else{
                    vx=-1;vy=0;v=1;u=4;
                }
            }
            //printf("%d\n",-1);
            while (1){
                //printf("%d,%d %d\n",f%w,f/w,v);
                map[f%w][f/w]|=v;
                f+=vx+vy*w;
                //printf("%d,%d %d\n",f%w,f/w,u);
                map[f%w][f/w]|=u;
                if (f==t) break;
            }
        }
    }
    //for (y=0;y<h;y++){
    //    for (x=0;x<w;x++)
    //        printf("%d ",map[x][y]);
    //    printf("\n");
    //}
    
    open[iopen][0]=0;
    open[iopen++][1]=0;
    
    while (iopen>0){
        i=open[--iopen][0];
        x=i%w;
        y=i/w;
        c=open[iopen][1];
        v=map[x][y];
        if (x==w-1&&y==h-1){printf("%d\n",j);exit(0);}
        for (j=0;j<iclose;j++) if (close[j]==i) goto l_lc;
        if (0<x  &&(v&0b0001)){open[iopen][0]=i-1;open[iopen++][1]=c+1;}
        if (0<y  &&(v&0b0010)){open[iopen][0]=i-w;open[iopen++][1]=c+1;}
        if (x<w-1&&(v&0b0100)){open[iopen][0]=i+1;open[iopen++][1]=c+1;}
        if (y<h-1&&(v&0b1000)){open[iopen][0]=i+w;open[iopen++][1]=c+1;}
        close[iclose++]=i;
    l_lc:
        continue;
    }
    
    printf("Odekakedekinai..\n");
    
    return 0;
}
0