Gym 101149L Right Build

本文探讨了在MMORPG《Path of Exile》中,如何利用最少的天赋点数快速获取特定的两项强力天赋。通过分析游戏内角色升级过程中的依赖关系,采用图论中的最短路径算法,寻找从起始点到达目标点a和b的最优解。
L. Right Build
time limit per test
2.0 s
memory limit per test
256 MB
input
standard input
output
standard output

In a MMORPG «Path of Exile» characters grow by acquiring talents for special talent points received in a game process. Talents can depend on others. A talent can be acquired only if a character has at least one of the talents it depends on. Acquiring one talent costs one talent point. At the beginning of the game a character has a single starting talent.

Schoolboy Vasiliy decided to record a video manual how to level-up a character in a proper way, following which makes defeating other players and NPCs very easy. He numbered all  talents as integers from 0 to n, so that the starting talent is numbered as 0. Vasiliy thinks that the only right build is acquiring two different talents a and b as quickly as possible because these talents are imbalanced and much stronger than any others. Vasiliy is lost in thought what minimal number of talent points is sufficient to acquire these talents from the start of the game.

Input

The first line contains four space-separated integers: nma and b (2 ≤ n, m ≤ 2·1051 ≤ a, b ≤ na ≠ b) — the total number of talents, excluding the starting talent, the number of dependencies between talents, and the numbers of talents that must be acquired.

Each of the next m lines contains two space-separated integers: xj and yj (0 ≤ xj ≤ n1 ≤ yj ≤ nxj ≠ yj), which means the talent yjdepends on the talent xj. It's guaranteed that it's possible to acquire all  talents given the infinite number of talent points.

Output

Output a single integer — the minimal number of talent points sufficient to acquire talents a and b.

Examples
input
Copy
6 8 4 6
0 1
0 2
1 2
1 5
2 3
2 4
3 6
5 6
output
Copy
4
input
Copy
4 6 3 4
0 1
0 2
1 3
2 4
3 4
4 3
output
Copy
3

 

【题意】

给出一个n个点m条边的有向连通图每次只有起点可以用终点才可以用,初始时0点可以用,问最少要用多少点才能用到a点和b

 

【分析】

如果只是要用一个点a,那么求0->a的最短路即可,但是要用两个点就可能0->a0->b都不是最短路,但是由于路径重叠很多点可以被用两次以节省用的点数,但是注意到两条路径只会是开始时重叠在一次,之后分开就再也不会相交,因为如果再次相交不如之前全部重叠更优,那么我们枚举这个叉点c,求出0->c,a->c,b->c的最短路来更新最优解即可

 

【代码】

#include<queue>
#include<vector>
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
const int N=2e5+5;
typedef long long ll;
#define pir pair<int,int>
#define m(s) memset(s,0,sizeof s);
int n,m,a,b,dis[3][N];
struct node{int v,w,next;}e[N<<2];int tot,head[N];bool vis[N];
struct data{int x,y,z;}ed[N];
inline void add(int x,int y,int z){
	e[++tot].v=y;e[tot].w=z;e[tot].next=head[x];head[x]=tot;
}
inline void Init(){
	scanf("%d%d%d%d",&n,&m,&a,&b);
	for(int i=1;i<=m;i++) scanf("%d%d",&ed[i].x,&ed[i].y),add(ed[i].x+1,ed[i].y+1,1);
	memset(dis[0],0x3f,sizeof dis[0]);
}
#define mp make_pair
inline void dijkstra(int S,int t){
	priority_queue<pir,vector<pir>,greater<pir> >q;
	q.push(mp(dis[t][S]=0,S));
	while(!q.empty()){
		pir p=q.top();q.pop();
		int x=p.second;
		if(vis[x]) continue;
		vis[x]=1;
		for(int i=head[x];i;i=e[i].next){
			int v=e[i].v;
			if(!vis[v]&&dis[t][v]>dis[t][x]+e[i].w){
				q.push(mp(dis[t][v]=dis[t][x]+e[i].w,v));
			}
		}
	}
}
inline void out(int x){
	for(int i=1;i<=n+1;i++) printf("%12d",dis[x][i]);puts("");
}
inline void Solve(){
	dijkstra(1,0);
	tot=0;m(head);
	for(int i=1;i<=m;i++) add(ed[i].y+1,ed[i].x+1,1);
	m(vis);memset(dis[1],0x3f,sizeof dis[1]);
	dijkstra(++a,1);
	m(vis);memset(dis[2],0x3f,sizeof dis[2]);
	dijkstra(++b,2);
	int ans=2e9;
	for(int i=1;i<=n+1;i++) ans=(int)min((ll)ans,(ll)dis[0][i]+dis[1][i]+dis[2][i]);
	printf("%d",ans);
}
int main(){
	Init();
	Solve();
	return 0;
} 

 

转载于:https://www.cnblogs.com/shenben/p/10420864.html

(jjp) arx@arx:~/isaac/ts_rc/legged_gym/legged_gym/scripts$ pip install mujoco Requirement already satisfied: mujoco in /home/arx/miniconda3/envs/jjp/lib/python3.8/site-packages (2.3.7) Requirement already satisfied: absl-py in /home/arx/miniconda3/envs/jjp/lib/python3.8/site-packages (from mujoco) (2.3.1) Requirement already satisfied: glfw in /home/arx/miniconda3/envs/jjp/lib/python3.8/site-packages (from mujoco) (2.9.0) Requirement already satisfied: numpy in /home/arx/miniconda3/envs/jjp/lib/python3.8/site-packages (from mujoco) (1.24.4) Requirement already satisfied: pyopengl in /home/arx/miniconda3/envs/jjp/lib/python3.8/site-packages (from mujoco) (3.1.9) (jjp) arx@arx:~/isaac/ts_rc/legged_gym/legged_gym/scripts$ python sim2sim.py Importing module 'gym_38' (/home/arx/isaac/isaacgym1/isaacgym/python/isaacgym/_bindings/linux-x86_64/gym_38.so) Setting GYM_USD_PLUG_INFO_PATH to /home/arx/isaac/isaacgym1/isaacgym/python/isaacgym/_bindings/linux-x86_64/usd/plugInfo.json PyTorch version 2.4.1+cu121 Device count 1 /home/arx/isaac/isaacgym1/isaacgym/python/isaacgym/_bindings/src/gymtorch Using /home/arx/.cache/torch_extensions/py38_cu121 as PyTorch extensions root... Emitting ninja build file /home/arx/.cache/torch_extensions/py38_cu121/gymtorch/build.ninja... Building extension module gymtorch... Allowing ninja to set a default number of workers... (overridable by setting the environment variable MAX_JOBS=N) ninja: no work to do. Loading extension module gymtorch... Use arrow keys to move the robot. 'l': turn left 'r': turn left UP: move forward, DOWN: move backward, LEFT: move left, RIGHT: move right. Traceback (most recent call last): File "sim2sim.py", line 165, in <module> model = mujoco.MjModel.from_xml_path(Sim2simCfg.sim_config.mujoco_model_path)#载入初始化位置由XML决定 ValueError: XML Error: Schema violation: unrecognized attribute: 'actuatorfrcrange' Element 'joint', line 0
07-18
演示了为无线无人机电池充电设计的感应电力传输(IPT)系统 Dynamic Wireless Charging for (UAV) using Inductive Coupling 模拟了为无人机(UAV)量身定制的无线电力传输(WPT)系统。该模型演示了直流电到高频交流电的转换,通过磁共振在气隙中无线传输能量,以及整流回直流电用于电池充电。 系统拓扑包括: 输入级:使用IGBT/二极管开关连接到全桥逆变器的直流电压源(12V)。 开关控制:脉冲发生器以85 kHz(周期:1/85000秒)的开关频率运行,这是SAE J2954无线充电标准的标准频率。 耦合级:使用互感和线性变压器块来模拟具有特定耦合系数的发射(Tx)和接收(Rx)线圈。 补偿:包括串联RLC分支,用于模拟谐振补偿网络(将线圈调谐到谐振频率)。 输出级:桥式整流器(基于二极管),用于将高频交流电转换回直流电,以供负载使用。 仪器:使用示波器块进行全面的电压和电流测量,用于分析输入/输出波形和效率。 模拟详细信息: 求解器:离散Tustin/向后Euler(通过powergui)。 采样时间:50e-6秒。 4.主要特点 高频逆变:模拟85 kHz下IGBT的开关瞬态。 磁耦合:模拟无人机着陆垫和机载接收器之间的松耦合行为。 Power GUI集成:用于专用电力系统离散仿真的设置。 波形分析:预配置的范围,用于查看逆变器输出电压、初级/次级电流和整流直流电压。 5.安装与使用 确保您已安装MATLAB和Simulink。 所需工具箱:必须安装Simscape Electrical(以前称为SimPowerSystems)工具箱才能运行sps_lib块。 打开文件并运行模拟。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值