当前位置:网站首页>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
边栏推荐
- 单例 DCL(double check lock) 饱汉模式和饿汉模式
- P6 ali machine test of 2020 Fibonacci number
- Fragments
- 重要消息丨.NET Core 3.1 将于今年12月13日结束支持
- Altium designer software commonly used the most complete package library, including schematic library, PCB library and 3D model library
- 我入职阿里后,才知道原来简历这么写
- 【MySQL】update mysql.user set authentication_string=password(“123456“) where User=‘root‘; 报错
- 【ROS2原理8】节点到参与者的重映射
- 线程池总结
- Codeforces Round #359 (Div. 2) C. Robbers' watch 暴力枚举
猜你喜欢
差分约束-图论
基于布朗运动的文本生成方法-LANGUAGE MODELING VIA STOCHASTIC PROCESSES
【Oracle 11g】Redhat 6.5 安装 Oracle11g
【nuxt】服务器部署步骤
虚拟机网卡报错:Bringing up interface eth0: Error: No suitable device found: no device found for connection
报错:FSADeprecationWarning: SQLALCHEMY_TRACK_MODIFICATIONS重大开销和将disab补充道
无重复的字符的最长子串
学习小笔记---机器学习
字节跳动面试题之镜像二叉树2020
jvm线程状态
随机推荐
AD picture PCB tutorial 20 minutes clear label shop operation process, copper network
用tensorflow.keras模块化搭建神经网络模型
SAP ALV 数据导出被截断的bug
vlucas/phpdotenv phpdotenv获取变量内容偶尔出现返回false
我入职阿里后,才知道原来简历这么写
P6阿里机试题之2020 斐波那契数
详解C语言中的wait()函数和waitpid()函数
单例 DCL(double check lock) 饱汉模式和饿汉模式
Integer 线程安全的
VS2019 common shortcut keys
高项 03 项目立项管理
car-price-deeplearning-0411
bzoj 5333 [Sdoi2018]荣誉称号
【ROS2原理8】节点到参与者的重映射
95后,刚工作2-3年就年薪50W+ ,才发现打败我们的,从来不是年龄···
APP product source data interface (taobao, jingdong/spelling/suning/trill platform details a lot data analysis interface) code and docking tutorial
rsync:recv_generator: mkdir (in backup) failed:Permission denied (13) |failed to set times on '.'
顺序表删除所有值为e的元素
e-learning summary
2022 年全球十大最佳自动化测试工具