博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
UVA Planning mobile robot on Tree树上的机器人(状态压缩+bfs)
阅读量:7048 次
发布时间:2019-06-28

本文共 1076 字,大约阅读时间需要 3 分钟。

用(x,s)表示一个状态,x表示机器人的位置,s表示其他位置有没有物体。用个fa数组和act数组记录和打印路径,转移的时候判断一下是不是机器人在动。

#include
using namespace std;const int maxn = 16;const int maxe = 32;const int MAXSTA = 491520+10; // 2^15*15int head[maxn],to[maxe],nxt[maxe];int ecnt;void addEdge(int u,int v){ to[ecnt] = v; nxt[ecnt] = head[u]; head[u] = ecnt++;}struct Node{ int x,s; Node(){} Node(int X ,int S ){ x = X; s = S; }}q[MAXSTA];int fa[MAXSTA],dist[MAXSTA];struct Act{ int u,v; Act(int U = 0,int V = 0):u(U),v(V){}}act[MAXSTA];bool vis[32768][15];int n,m,s,t,sta;void print_ans(int u){ if(~fa[u])print_ans(fa[u]); else return; printf("%d %d\n",act[u].u+1,act[u].v+1);}void bfs(){ int _front = 0,rear = 0; q[rear].x = s; q[rear].s = sta; fa[rear] = -1; dist[rear++] = 0; memset(vis,0,sizeof(vis)); vis[sta][s] = true; while(_front
>who&1){ int newSta = u.s^(1<
>to[i]&1)^1) { Node &v = q[rear]; v.s = newSta|1<

 

转载于:https://www.cnblogs.com/jerryRey/p/4691795.html

你可能感兴趣的文章
前端代码规范
查看>>
UITableView:下拉刷新和上拉加载更多
查看>>
CFileDialog
查看>>
centOS Python 安装2.7以上版本
查看>>
最近気になる清掃
查看>>
C语言下的简易计算器
查看>>
git 分支
查看>>
一类分治问题
查看>>
[ZJOI2017]树状数组
查看>>
Android SDK无法更新问题解决
查看>>
LeetCode – Refresh – N-Queens II
查看>>
LeetCode 639: DecodeWaysII
查看>>
Linux系统简介--LInix系统随笔(一)
查看>>
TCP接入层的负载均衡、高可用、扩展性架构
查看>>
使用Kieker(AspectJ)监控控制台程序
查看>>
C#多线程之旅(1)——介绍和基本概念
查看>>
Spring常用注解汇总
查看>>
10大最重要的Web安全风险之六--A6-安全误配置
查看>>
Hibernate【与Spring整合】
查看>>
NOIP2018 游记
查看>>