当前位置:网站首页>2017 G icpc shenyang Infinite Fraction Path BFS + pruning
2017 G icpc shenyang Infinite Fraction Path BFS + pruning
2022-08-09 07:02:00 【swust_fang】
The meaning of the question: Given a string array of length n, you can select the starting point to jump n times, from point i can only jump to the position of (i*i+1)%n, and finally find a maximum lexicographical order.
Ideas: The largest number is required, that is, each step is the largest, so the largest number is entered into the team for bfs to jump to the next step.
Pruning: 1. If the point jumping to the next step is smaller than other points jumping to the next step, remove it
2. If there are two points that reach the same point through the same synchronization number, then their subsequent states are also the same, so they are also eliminated.
ok, it is all.
First we use a structure to wrap the number of steps and the position pos node{step,pos}
Use the nex array to represent the value of the number from the pos point to the next position
Then we customize a sorting function in the priority queue (the most important pruning is actually the sorting method)
If the value of step and the next step nex[pos] are equal, we sort by pos from small to large
If step is equal, nex[pos] is not equal, according to nex[pos] from big to small
If the steps are not equal, follow the steps from small to large
Pit!!!Pay attention to i*i burst int, disgusting
#include#include#include#include#include#include#include#include#include
边栏推荐
- 详解C语言中的wait()函数和waitpid()函数
- 【Shell】查找进程的pid并根据pid获取该进程所占用的端口号以及该进程在系统中所下达的指令名称
- Use baidu EasyDL intelligent bin
- bzoj 5333 [Sdoi2018]荣誉称号
- 95后,刚工作2-3年就年薪50W+ ,才发现打败我们的,从来不是年龄···
- P7阿里面试题2020.07 之滑动窗算法(阿里云面试)
- car-price-deeplearning-0411
- MUI无法滚动?完美解决
- Singleton DCL (double check the lock) full han mode and the hungry
- 我入职阿里后,才知道原来简历这么写
猜你喜欢
随机推荐
SSL证书最长有效期13个月,还有必要一次申请多年吗?
P6阿里机试题之2020 斐波那契数
集合内之部原理总结
力扣第 305 场周赛复盘
子路由及路由出口配置
MUI无法滚动?完美解决
【ROS2原理8】节点到参与者的重映射
多米诺骨牌
dp学习笔记
Inception V3 Eye Closure Detection
浅识微服务架构
Altium designer software commonly used the most complete package library, including schematic library, PCB library and 3D model library
C语言的内置宏(定义日志宏)
mysql summary
codeforces Valera and Elections (这思维题是做不明白了)
AD的library中 库文件后缀有.intlib .schlib .pcblib 的区别
报错:FSADeprecationWarning: SQLALCHEMY_TRACK_MODIFICATIONS重大开销和将disab补充道
Example of using the cut command
APP product source data interface (taobao, jingdong/spelling/suning/trill platform details a lot data analysis interface) code and docking tutorial
String.toLowerCase(Locale.ROOT)