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 |
郁闷呀,一个低级错误让我改了几个小时In Reply To:都考虑了,而且还写了几个版本 Posted by:windbells at 2004-11-04 13:45:43 > nun[i][j].n[k]分别表示从这一点到上,左,左上,右上有几个连续的点 > > > #include<stdio.h> > #include<string.h> > typedef struct > { > int n[4]; > }nod; > #define Max 22 > nod num[Max][Max]; > int clj[4][2]={{0,-1},{-1,0},{-1,-1},{-1,1}}; > int map[Max][Max]; > int r,c,b[3]; > void init() > { > int i,j,k,tmp; > memset(map,0,sizeof(map)); > for(i=1;i<20;i++) > for(j=1;j<20;j++) > { > scanf("%d",&tmp); > map[i][j]=tmp; > } > for(i=0;i<=20;i++) > for(j=0;j<=20;j++) > for(k=0;k<3;k++) for(i=0;i<=3;i++) > num[i][j].n[k]=1; > for(i=1;i<3;i++) > b[i]=0; > } > void solve() > { > int i,j,k,tmpr,tmpc; > for(i=1;i<=19;i++) > for(j=1;j<=19;j++) > { > if(map[i][j]==0) > continue; > for(k=0;k<4;k++) > { > tmpr=i+clj[k][0]; > tmpc=j+clj[k][1]; > if(map[i][j]==map[tmpr][tmpc]) > { > num[i][j].n[k]=num[tmpr][tmpc].n[k]+1; > if(num[i][j].n[k]==5&&map[i][j]!=map[i-clj[k][0]][j-clj[k][1]]) > { > b[map[i][j]]=1; > if(k==3){ r=i;c=j; } > else { r=i+4*clj[k][0];c=j+4*clj[k][1]; } > return ; > } > } > } > } > } > void print() > { > int i; > for(i=1;i<3;i++) > if(b[i]==1) > break; > if(i==3) > printf("0\n"); > else > printf("%d\n%d %d\n",i,r,c); > } > int main() > { > int t; > scanf("%d",&t); > while(t--) > { > init(); > solve(); > print(); > } > return 0; > } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator