这运行错误是神马情况

xiaobing 2022-05-16 21:54:54 32 返回题目

#include<bits/stdc++.h> using namespace std; queuex,y; int c[12][2]={{1,2},{1,-2},{-1,2},{-1,-2},{2,1},{2,-1},{-2,1},{-2,-1},{2,2},{2,-2},{-2,2},{-2,-2}}; bool d[101][101],e[101][101]; int f(int a,int b) { x.push(a); y.push(b); x.push(1000); y.push(1000); int s=0; while(1) { // cout<<x.front()<<" "<<y.front()<<" "<<x.size()<<endl; if(x.front()==1&&y.front()==1)break; if(!x.size()&&!y.size())break; if(x.front()==y.front()&&x.front()>=1000) { s++; x.push(1000); y.push(1000); x.pop(); y.pop(); } for(int i=1;i<=12;i++) { if(!d[x.front()+c[i][1]][y.front()+c[i][2]]&&x.front()+c[i][1]<=100&&y.front()+c[i][2]<=100&&x.front()+c[i][1]>0&&y.front()+c[i][2]>0) { x.push(x.front()+c[i][1]); y.push(y.front()+c[i][2]); d[x.front()+c[i][1]][y.front()+c[i][2]]=1; } } x.pop(); y.pop(); } return s; } int f1(int a,int b) { x.push(a); y.push(b); x.push(1000); y.push(1000); int s=0; while(1) { // cout<<x.front()<<" "<<y.front()<<" "<<x.size()<<endl; if(x.front()==1&&y.front()==1)break; if(!x.size()&&!y.size())break; if(x.front()==y.front()&&x.front()>=1000) { s++; x.push(1000); y.push(1000); x.pop(); y.pop(); } for(int i=1;i<=12;i++) { if(!e[x.front()+c[i][1]][y.front()+c[i][2]]&&x.front()+c[i][1]<=100&&y.front()+c[i][2]<=100&&x.front()+c[i][1]>0&&y.front()+c[i][2]>0) { x.push(x.front()+c[i][1]); y.push(y.front()+c[i][2]); e[x.front()+c[i][1]][y.front()+c[i][2]]=1; } } x.pop(); y.pop(); } return s; } int main() { int a,b; cin>>a>>b; cout<<f(a,b)<<endl; while(x.size())x.pop(),y.pop(); cin>>a>>b; cout<<f1(a,b); return 0; }

{{ vote && vote.total.up }}