Submission #163610


Source Code Expand

#include<stdio.h>
struct complex{
	short y;
	short x;
};
struct complex place[2500];
char c[50][51];
short num[50][50];
short count=1;
void tansaku(int y,int x,int n){
	if(num[y-1][x]==-1 && c[y-1][x]=='.'){
		num[y-1][x]=n+1;
		place[count].x=x;
		place[count].y=y-1;
		count++;
	}
	if(num[y+1][x]==-1 && c[y+1][x]=='.'){
		num[y+1][x]=n+1;
		place[count].x=x;
		place[count].y=y+1;
		count++;
		
	}
	//puts("OK");
	if(num[y][x-1]==-1 && c[y][x-1]=='.'){
		num[y][x-1]=n+1;
		place[count].x=x-1;
		place[count].y=y;
		count++;
	}
	if(num[y][x+1]==-1 && c[y][x+1]=='.'){
		num[y][x+1]=n+1;
		place[count].x=x+1;
		place[count].y=y;
		count++;
	}
	return;
}

int main(void){
	int r,l,sy,sx,gy,gx;
	char enter;
	int i,j;
	scanf("%d %d",&r,&l);
	scanf("%d %d",&sy,&sx);
	scanf("%d %d",&gy,&gx);
	
	for(i=0;i<r;i++){
		for(j=0;j<l;j++){
			scanf(" %c",&c[i][j]);
		}
	}
	for(i=0;i<r;i++){
		for(j=0;j<l;j++){
			num[i][j]=-1;
		}
	}

	place[0].x=sx-1;
	place[0].y=sy-1;
	num[place[0].y][place[0].x]=0;
	
	for(i=0;;i++){
		if(num[gy-1][gx-1]!=-1) break;
		tansaku(place[i].y,place[i].x,num[place[i].y][place[i].x]);
	}

	
	printf("%d\n",num[gy-1][gx-1]);
	return 0;
}

Submission Info

Submission Time
Task C - 幅優先探索
User ovoriruovo
Language C (GCC 4.6.4)
Score 100
Code Size 1234 Byte
Status AC
Exec Time 23 ms
Memory 796 KB

Compile Error

./Main.c: In function ‘main’:
./Main.c:44:7: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
./Main.c:45:7: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
./Main.c:46:7: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
./Main.c:50:9: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 100 / 100
Status
AC × 3
AC × 25
Set Name Test Cases
Sample subtask0_sample01.txt, subtask0_sample02.txt, subtask0_sample03.txt
All subtask0_sample01.txt, subtask0_sample02.txt, subtask0_sample03.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_16.txt, subtask1_17.txt, subtask1_18.txt, subtask1_19.txt, subtask1_20.txt, subtask1_21.txt, subtask1_22.txt
Case Name Status Exec Time Memory
subtask0_sample01.txt AC 20 ms 792 KB
subtask0_sample02.txt AC 20 ms 792 KB
subtask0_sample03.txt AC 19 ms 792 KB
subtask1_01.txt AC 18 ms 784 KB
subtask1_02.txt AC 23 ms 792 KB
subtask1_03.txt AC 22 ms 788 KB
subtask1_04.txt AC 21 ms 696 KB
subtask1_05.txt AC 21 ms 788 KB
subtask1_06.txt AC 21 ms 796 KB
subtask1_07.txt AC 18 ms 784 KB
subtask1_08.txt AC 21 ms 796 KB
subtask1_09.txt AC 21 ms 792 KB
subtask1_10.txt AC 20 ms 792 KB
subtask1_11.txt AC 21 ms 784 KB
subtask1_12.txt AC 21 ms 716 KB
subtask1_13.txt AC 20 ms 788 KB
subtask1_14.txt AC 19 ms 788 KB
subtask1_15.txt AC 19 ms 792 KB
subtask1_16.txt AC 19 ms 792 KB
subtask1_17.txt AC 19 ms 700 KB
subtask1_18.txt AC 19 ms 788 KB
subtask1_19.txt AC 21 ms 788 KB
subtask1_20.txt AC 21 ms 796 KB
subtask1_21.txt AC 22 ms 792 KB
subtask1_22.txt AC 21 ms 696 KB