結果
問題 | No.340 雪の足跡 |
ユーザー |
|
提出日時 | 2016-01-30 20:09:55 |
言語 | C90 (gcc 12.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,044 bytes |
コンパイル時間 | 1,003 ms |
コンパイル使用メモリ | 22,656 KB |
実行使用メモリ | 13,760 KB |
最終ジャッジ日時 | 2024-09-21 19:27:17 |
合計ジャッジ時間 | 4,251 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 WA * 2 |
other | AC * 3 WA * 12 TLE * 1 -- * 16 |
コンパイルメッセージ
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); | ^~~~~~~~~~~~~~
ソースコード
#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; }