CE???
查看原帖
CE???
1034688
_Geburah楼主2024/4/20 19:44
#include<bits/stdc++.h>
using namespace std;
char a[11][11];
int x1,y1,x2,y2,chao1=1,chao2=1,time1;
void out()
{
	if(time1==2147483647)cout<<"0";
	else cout<<time1;
}
void move()
{
	while(x1!=x2||y1!=y2&&time1<=2147483646)
	{
		time1++;
		if(chao1==1)
		{
			if(x1!=01&&a[x1-1][y1]!='*')x1--;
			else chao1++;
		}
		else if(chao1==2)
		{
			if(y1!=10&&a[x1][y1+1]!='*')y1++;
			else chao1++;
		}
		else if(chao1==3)
		{
			if(x1!=10&&a[x1+1][y1]!='*')x1++;
			else chao1++;
		}
		else if(chao1==4)
		{
			if(y1!=01&&a[x1][y1-1]!='*')y1--;
			else chao1-=3;
		}
		if(chao2==1)
		{
			if(x2!=01&&a[x2-1][y2]!='*')x2--;
			else chao2++;
		}
		else if(chao2==2)
		{
			if(y2!=10&&a[x2][y2+1]!='*')y2++;
			else chao2++;
		}
		else if(chao2==3)
		{
			if(x2!=10&&a[x2+1][y2]!='*')x2++;
			else chao2++;
		}
		else if(chao2==4)
		{
			if(y2!=01&&a[x2][y2-1]!='*')y2--;
			else chao2-=3;
		}
	}
	out();
}
void in()
{
	for(int i=1;i<=10;i++)
	{
		for(int j=1;j<=10;j++)
		{
			cin>>a[i][j];
			if(a[i][j]=='F')
			{
				x1=i;
				y1=j;
			}
			else if(a[i][j]=='C')
			{
				x2=i;
				y2=j;
			}
		}
	}
	move();
}
int main(){
	in();
	return 0;
}
2024/4/20 19:44
加载中...