Submission #162810


Source Code Expand

#include <stdio.h>
#include <string.h>


int main(void)
{
	int r_siz,c_siz;
	int sy,sx,gy,gx;
	char c[51][51];
	char chk[51][51]={0};
	int i,j;
	int stk1y[2500],stk1x[2500];
	int stk2y[2500],stk2x[2500];
	int bank;
	int sp1,sp2;
	int count = 0;

	scanf("%d %d",&r_siz,&c_siz);
	scanf("%d %d",&sy,&sx);
	scanf("%d %d",&gy,&gx);

	for(i=0;i<r_siz;i++){
		scanf("\n");
		for(j=0;j<c_siz;j++){
			scanf("%c",&c[i][j]);
			if(c[i][j]==35)chk[i][j]=1;
		}
	}

	chk[sy-1][sx-1]=1;
	stk1y[0] = sy-1;
	stk1x[0] = sx-1;
	sp1 = 1;
	sp2 = 0;
	while(1){
//		printf("%d\n",sp1);
		count++;
		if(sp1==0)break;
		while(sp1!=0){
			sp1--;
			if(chk[stk1y[sp1]+1][stk1x[sp1]]==0){
				stk2y[sp2] = stk1y[sp1]+1;
				stk2x[sp2] = stk1x[sp1];
				chk[stk2y[sp2]][stk2x[sp2]]=count;
				sp2++;
			}
			if(chk[stk1y[sp1]-1][stk1x[sp1]]==0){
				stk2y[sp2] = stk1y[sp1]-1;
				stk2x[sp2] = stk1x[sp1];
				chk[stk2y[sp2]][stk2x[sp2]]=count;
				sp2++;
			}
			if(chk[stk1y[sp1]][stk1x[sp1]+1]==0){
				stk2y[sp2] = stk1y[sp1];
				stk2x[sp2] = stk1x[sp1]+1;
				chk[stk2y[sp2]][stk2x[sp2]]=count;
				sp2++;
			}
			if(chk[stk1y[sp1]][stk1x[sp1]-1]==0){
				stk2y[sp2] = stk1y[sp1];
				stk2x[sp2] = stk1x[sp1]-1;
				chk[stk2y[sp2]][stk2x[sp2]]=count;
				sp2++;
			}
		}
//		printf("%d\n",sp2);
		count++;
		if(sp2==0)break;
		while(sp2!=0){
			sp2--;
			if(chk[stk2y[sp2]+1][stk2x[sp2]]==0){
				stk1y[sp1] = stk2y[sp2]+1;
				stk1x[sp1] = stk2x[sp2];
				chk[stk1y[sp1]][stk1x[sp1]]=count;
				sp1++;
			}
			if(chk[stk2y[sp2]-1][stk2x[sp2]]==0){
				stk1y[sp1] = stk2y[sp2]-1;
				stk1x[sp1] = stk2x[sp2];
				chk[stk1y[sp1]][stk1x[sp1]]=count;
				sp1++;
			}
			if(chk[stk2y[sp2]][stk2x[sp2]+1]==0){
				stk1y[sp1] = stk2y[sp2];
				stk1x[sp1] = stk2x[sp2]+1;
				chk[stk1y[sp1]][stk1x[sp1]]=count;
				sp1++;
			}
			if(chk[stk2y[sp2]][stk2x[sp2]-1]==0){
				stk1y[sp1] = stk2y[sp2];
				stk1x[sp1] = stk2x[sp2]-1;
				chk[stk1y[sp1]][stk1x[sp1]]=count;
				sp1++;
			}
		}
	}

	printf("%d\n",chk[gy-1][gx-1]);

	return 0;
}


Submission Info

Submission Time
Task C - 幅優先探索
User vict
Language C++ (G++ 4.6.4)
Score 0
Code Size 2115 Byte
Status WA
Exec Time 20 ms
Memory 804 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:18:30: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
./Main.cpp:19:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
./Main.cpp:20:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
./Main.cpp:23:14: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
./Main.cpp:25:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 100
Status
AC × 3
AC × 16
WA × 9
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 19 ms 684 KB
subtask0_sample02.txt AC 19 ms 800 KB
subtask0_sample03.txt AC 18 ms 800 KB
subtask1_01.txt WA 20 ms 792 KB
subtask1_02.txt WA 20 ms 804 KB
subtask1_03.txt AC 19 ms 804 KB
subtask1_04.txt AC 20 ms 792 KB
subtask1_05.txt AC 19 ms 800 KB
subtask1_06.txt WA 20 ms 804 KB
subtask1_07.txt AC 19 ms 800 KB
subtask1_08.txt WA 20 ms 796 KB
subtask1_09.txt AC 20 ms 684 KB
subtask1_10.txt WA 20 ms 804 KB
subtask1_11.txt AC 19 ms 684 KB
subtask1_12.txt AC 19 ms 704 KB
subtask1_13.txt AC 19 ms 796 KB
subtask1_14.txt AC 18 ms 668 KB
subtask1_15.txt AC 20 ms 696 KB
subtask1_16.txt AC 20 ms 804 KB
subtask1_17.txt AC 19 ms 700 KB
subtask1_18.txt AC 19 ms 684 KB
subtask1_19.txt WA 19 ms 692 KB
subtask1_20.txt WA 19 ms 800 KB
subtask1_21.txt WA 19 ms 792 KB
subtask1_22.txt WA 20 ms 672 KB