gym100959I Robots 2015-2016 Petrozavodsk Winter Training Camp, Makoto rng_58 Soejima Сontest 4

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

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});
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值