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 |
Re:提交了30次,才WA!【附】原因In Reply To:Re:提交了30次,才WA!【附】原因 Posted by:spracle_hao at 2009-03-23 16:15:34 能帮我看看我错在哪里吗? 谢谢!! #include<iostream> #include <string.h> using namespace std; int n,c,r,sum=0;//c是列;r是行 int map[50][50]; int Xstep[8]={-2, -2, -1, -1, 1, 1, 2, 2}; int Ystep[8]={-1, 1, -2, 2, -2, 2, -1, 1}; int arr[100][2]; bool ok; void solve(int m,int n,int num) { if(ok) return; int i,j; int a,b; arr[num][0]=m;arr[num][1]=n; if(num==sum) { ok=true; return; } for(i=0;i<8;i++) { a=m+Xstep[i]; b=n+Ystep[i]; if(a>0 && b>0 && a<=c && b<=r && map[a][b]==0) { map[a][b]=1; solve(a,b,num+1); map[a][b]=0; } } } int main() { cin>>n; int x=1; while(n--) { memset(map,0,sizeof(map));//初始化 cin>>c>>r; sum=c*r; map[1][1]=1; solve(1,1,1); cout<<"Scenario #"<<x<<":"<<endl; x=x+1; if (ok) { for(int i=1;i<=sum ;i++) printf("%c%c", arr[i][1] + 'A' - 1 , arr[i][0] + '0' ) ; } else cout<<"impossible"; cout<<endl<<endl; } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator