P1747 好奇怪的游戏 一道搜索的模拟题,注意细节。
#include
using namespace std;
struct node
{
int x,y;
int step;
};
int dx[12]={2,-2,2,-2,1,1,-1,-1,2,2,-2,-2};
int dy[12]={2,2,-2,-2,2,-2,2,-2,1,-1,1,-1};
bool vis[1000][1000];
queueq;
void bfs(int x,int y)
{
node cur,nxt;
cur.x=x;
cur.y=y;
cur.step=0;
q.push(cur);
vis[x][y]=1;
while(!q.empty())
{
cur=q.front();
q.pop();
if(cur.x==1&&cur.y==1)
{
cout>y_1>>x2>>y2;
bfs(x1,y_1);
memset(vis,0,sizeof(vis));
while(!q.empty()) //²»Îª¿Õʱ·µ»Ø0
q.pop();
bfs(x2,y2);
return 0;
}
一道省赛思维题,难点在于题意得理解,不过根据样例也能猜的八九不离十。思维上对于我来说也是有点难度。。。。
#include
using namespace std;
const int N=3e5+5;
int n,ans1,ans2,a[N],b[N];
int main()
{
cin>>n;
for(int i=1;i>x>>y;
ans1+=4;ans2+=4;
if(a[x])
ans1-=2;
if(b[x])
ans2-=2;
if(a[x]=1&&a[x]
关注
打赏