标签:起点 计算 blog down for using efi span style
格子游戏
1 #include<iostream> 2 #include<cstdio> 3 #define Maxn 2002 4 5 using namespace std; 6 7 int n,m; 8 9 struct zuobiao{ 10 int x,y; 11 }zb[Maxn][Maxn],f1,f2; 12 13 zuobiao gz(zuobiao q) 14 { 15 if(zb[q.x][q.y].x==q.x&&zb[q.x][q.y].y==q.y) return q; 16 zb[q.x][q.y]=gz(zb[q.x][q.y]); 17 return zb[q.x][q.y]; 18 } 19 int main() 20 { 21 int x,y; 22 char zifu; 23 scanf("%d%d",&n,&m); 24 for(int i=1;i<=n;i++)//初始化操作 25 { 26 for(int j=1;j<=n;j++) 27 { 28 zb[i][j].x=i; 29 zb[i][j].y=j; 30 } 31 } 32 for(int i=1;i<=m;i++) 33 { 34 cin>>x>>y>>zifu; 35 if(zifu==‘D‘)//down 36 { 37 f1=gz(zb[x][y]); 38 f2=gz(zb[x+1][y]); 39 } 40 if(zifu==‘R‘)//right 41 { 42 f1=gz(zb[x][y]); 43 f2=gz(zb[x][y+1]); 44 } 45 if(f1.x==f2.x&&f1.y==f2.y) 46 { 47 cout<<i<<endl; 48 return 0; 49 } 50 else zb[f1.x][f1.y]=f2; 51 } 52 cout<<"draw"<<endl; 53 return 0; 54 }
标签:起点 计算 blog down for using efi span style
原文地址:http://www.cnblogs.com/zxqxwnngztxx/p/6700878.html