|
|
вернуться в форумПоказать все сообщения Спрятать все сообщенияIs there always a path from the top left corner to the bottom right corner? Attached is my program which gets WA. Can anyone give me some tests (preferably those tests that make my program produce wrong answer)? #include <stdio.h> char map[34][34],v[34][34]; int n,count; const int x[4]={-1,0,1,0}; const int y[4]={0,1,0,-1}; void dfs(int i,int j){ int k; v[i][j]=1; for(k=0;k<4;k++){ if(i+x[k]<0 || i+x[k]>=n || j+y[k]<0 || j+y[k]>=n || map[i+x[k]][j+y[k]]=='#') count++; else if(!v[i+x[k]][j+y[k]]) dfs(i+x[k],j+y[k]); } } void main(){ int i,j; scanf("%d",&n); for(i=0;i<n;i++) scanf("%s",map[i]); for(i=0;i<n;i++) for(j=0;j<n;j++) v[i][j]=0; count=0L; dfs(0,0); printf("%d",9*(count-4)); } Try this map. 3 .#. ##. ... 108 |
|
|