题目描述 https://www.luogu.org/problemnew/show/P1518
模拟模拟模拟 变量名像注意不能打错,只有遇到障碍或是边界才能转方向,也只能顺时针转
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
bool fl;
int a[15][15],ans=1e5,cx,cy,fx,fy;
int d[4][2]={
{-1,0},{0,1},{1,0},{0,-1}};//0上1右2下3左
void dfs(int ncx,int ncy,int nfx,int nfy,int nc,int nf,int t)
{// 农夫的位置 牛的位置 农夫 牛的朝向 时间
if(ncx==nfx&&ncy==nfy)
{
ans=min(ans,t); fl=1;
return;
}
if(t>1e5) return;
int x1,y1,x2,y2,cc,ff; bool bc=0,bf=0;
x1=ncx+d[nc][0],y1=ncy+d[nc][1];
if(x1>=1&&x1<=10&&y1>=1&&y1<=10&&!a[x1][y1]) bc=1;//农夫能走
x2=nfx+d[nf][0],y2=nfy+d[nf][1];
if(x2>=1&&x2<=10&&y