https://codeforces.com/gym/100959/
对于每个机器人,我们都只记录上下左右可以激活它的最近的机器人是哪个,然后从那个连到他一条边,然后跑最短路就行了
因为只能走直的,所以相当于是个网格图,那么对于一个可激活别人的机器人,如果i能激活j,j能激活k,i也能激活k的话,那么就只需要连i->j->k,没必要连i->k了,那么总边数最多4n
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxl=1e5+10;
int n,m,cas,totx,toty;ll ans,T;
int xb[maxl],yb[maxl];
ll dis[maxl];
struct bot
{
int x,y,dir,id;
}a[maxl];
vector<bot> xa[maxl],ya[maxl];
struct ed{int v,l;};
vector<ed>e[maxl];
char s[2];
typedef pair<ll,int> p;
priority_queue<p,vector<p>,greater<p> >q;
inline bool cmpx(const bot &a,const bot &b){return a.x<b.x;}
inline bool cmpy(const bot &a,const bot &b){return a.y<b.y;}
inline int findid(int b[],int tot,int x)
{
return lower_bound(b+1,b+1+tot,x)-b;
}
inline void add(int u,int v,int l){e[u].push_back(ed{v,l});

该博客介绍了一种解决机器人激活问题的方法,通过记录每个机器人可激活的最近机器人,并构建网格图进行最短路径计算。文章详细阐述了如何预处理数据,构建边并进行最短路搜索,最后输出机器人的新位置。内容涉及图论和算法优化。
最低0.47元/天 解锁文章
1168

被折叠的 条评论
为什么被折叠?



