Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
谁能帮我举个反例说明我的错了。。。C代码,,#include "stdio.h" void search(int i,int j,long t); char a[1005][1005],b[1005][1005]; int p[]={0,0,1,-1},q[]={1,-1,0,0}; long u,v; void main() { int t; int i,j,k; int n,m,s; scanf("%d",&t); while(t--) { scanf("%d%d",&m,&n); for(i=0;i<n;i++) scanf("%s",b[i]); for(i=0;i<=n+1;i++) for(j=0;j<=m+1;j++) a[i][j]='#'; for(i=0;i<n;i++) for(j=0;j<m;j++) a[i+1][j+1]=b[i][j]; u=0; for(i=1;i<=n;i++) for(j=1;j<=m;j++) { if(a[i][j]=='.') {s=0; for(k=0;k<4;k++) if(a[i+p[k]][j+q[k]]=='#') s++; if(s>=3) { a[i][j]='#'; search(i,j,0); } } } printf("Maximum rope length is %ld.\n",u); } } void search(int i,int j,long t) { int x,y,k,ii=0; for(k=0;k<4;k++) { x=i+p[k]; y=j+q[k]; if(a[x][y]=='#') {ii++;continue;} a[x][y]='#'; search(x,y,t+1); ii=0; } if(ii==4&&t>u) u=t; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator