結果
| 問題 |
No.340 雪の足跡
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-01-30 19:09:24 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 1,964 bytes |
| コンパイル時間 | 288 ms |
| コンパイル使用メモリ | 22,272 KB |
| 実行使用メモリ | 813,184 KB |
| 最終ジャッジ日時 | 2024-09-21 19:27:02 |
| 合計ジャッジ時間 | 3,321 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 MLE * 1 -- * 3 |
| other | -- * 32 |
コンパイルメッセージ
main.c:22:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
22 | main(){
| ^~~~
main.c: In function ‘main’:
main.c:26:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
26 | scanf("%d%d%d",&w,&h,&n);
| ^~~~~~~~~~~~~~~~~~~~~~~~
main.c:33:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
33 | scanf("%d",&m);
| ^~~~~~~~~~~~~~
main.c:36:13: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
36 | scanf("%d",&k);
| ^~~~~~~~~~~~~~
ソースコード
#include <stdio.h>
int map[1000][1000];
int w,h,n;
int move(int x,int y,int f){
//static int cnt=0;
int r=0;
if (x==w-1 && y==h-1) return 0;
if (x<0||y<0||w<=x||h<=y) return 0x80000000;
//printf(">%d %d %d\n",x,y,map[x][y]);if (cnt++>5)exit(0);
if ((map[x][y]&0b0001)&&(f!=0b0001)) r=move(x-1,y,0b0100)+1;
if (r>0) return r;
if ((map[x][y]&0b0010)&&(f!=0b0010)) r=move(x,y-1,0b1000)+1;
if (r>0) return r;
if ((map[x][y]&0b0100)&&(f!=0b0100)) r=move(x+1,y,0b0001)+1;
if (r>0) return r;
if ((map[x][y]&0b1000)&&(f!=0b1000)) r=move(x,y+1,0b0010)+1;
if (r>0) return r;
return 0x80000000;
}
main(){
int i,j,k,m,x,y,f,t,vx,vy,v,u;
int ada[1000];
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");
//}
j=move(0,0,0);
if (j<0) printf("Odekakedekinai..\n");
else printf("%d\n",j);
return 0;
}