当前位置:网站首页>[7.21-26] code source - [good sequence] [social circle] [namonamo]
[7.21-26] code source - [good sequence] [social circle] [namonamo]
2022-07-29 01:49:00 【ZhgDgE】
#613. Good sequence
The question : There's a long one for n n n Sequence A 1 , A 2 , ⋯ , A n A_1,A_2,\cdots,A_n A1,A2,⋯,An . Define a sequence { A } \{A\} { A} Good. , If and only if each of his subintervals [ l , r ] [l,r] [l,r] Satisfy , At least one element exists x x x Only once . ( n ≤ 2 × 1 0 5 ) (n\leq 2\times 10^5) (n≤2×105)
Ideas : Heuristic divide and conquer . See 【 Heuristic divide and conquer 】 The inverse idea of heuristic merging
AC Code :http://oj.daimayuan.top/submission/299119
#606. Social circle
The question : Now there is N N N personal , Everyone doesn't want the people around him to sit close to him , So put it on his left L i L_i Li An empty chair , Put on the right R i R_i Ri An empty chair , At the same time, everyone should sit by themselves 1 1 1 A chair . Now they have to sit in circles , How many chairs should I put at least ( Including everyone's own chair )?
Ideas : hold { L } , { R } \{L\},\{R\} { L},{ R} Just sort and match , Such greed must be the least . So does this matching method have a solution , There must be a solution . Because this recombination match is similar to displacement , Permutation can be divided into several rings in graph theory , And topic meaning Several circles It's the same .
AC Code :http://oj.daimayuan.top/submission/298809
#678. namonamo
The question : Given string , Ask whether it can be split into two equal subsequences . ∣ S ∣ ≤ 40 |S|\leq 40 ∣S∣≤40
Answer key :( Half search ) Code source daily question Div1 namonamo
Ideas : We can pop search , however O ( 2 40 ) O(2^{40}) O(240) Is not workable . We can use half search , Search the first half and the second half of the sequence respectively , Then enumerate the search results on the left , Query on the right , Time complexity O ( 2 20 × log 2 20 ) O(2^{20}\times \log 2^{20}) O(220×log220) .
边栏推荐
- 【流放之路-第七章】
- Redis is installed on Linux
- 数据库的decimal类型的数据,发现可以通过resultSet.getDouble去拿到这个数据,但是通过getObject却拿不到这个属性。
- 剑指offer专项突击版第13天
- [search] - iteration deepening / bidirectional dfs/ida*
- 动态内存与智能指针
- AlphaFold揭示了蛋白质结构宇宙-从近100万个结构扩展到超过2亿个结构
- golang run时报undefined错误【已解决】
- The information security and Standardization Commission issued the draft for comments on the management guide for app personal information processing activities
- Autoware reports an error: can't generate global path for start solution
猜你喜欢

规划数学期末模拟考试一

规划数学期末考试模拟二

Super scientific and technological data leakage prevention system, control illegal Internet behaviors, and ensure enterprise information security

我们总结了 3 大Nacos使用建议,并首次公开 Nacos 3.0 规划图 Nacos 开源 4 周年

知道创宇上榜CCSIP 2022全景图多个领域

DSP震动座椅
![[unity project practice] synthetic watermelon](/img/60/20d4ef6f4ad99a9bdb7dc2b4dba23b.png)
[unity project practice] synthetic watermelon

OpenGL development with QT (II) drawing cube
![关于df[‘某一列名’][序号]](/img/e2/179fb4eda695726e87bb483f65e04e.png)
关于df[‘某一列名’][序号]

【公开课预告】:快手GPU/FPGA/ASIC异构平台的应用探索
随机推荐
Read the recent trends of okaleido tiger and tap the value and potential behind it
Six simple techniques to improve the value of penetration testing and save tens of thousands of yuan
Focus on differentiated product design, intelligent technology efficiency improvement and literacy education around new citizen Finance
Openpyxl merge cells
10 major network security incidents in the past 10 years
Network security litigation risk: four issues that chief information security officers are most concerned about
560 和为 K 的子数组
Top network security prediction: nearly one-third of countries will regulate blackmail software response within three years
LeetCode 112:路径总和
BOM系列之window对象
golang run时报undefined错误【已解决】
【Web技术】1395- Esbuild Bundler HMR
Ruiji takeout project actual battle day01
Data security is a competitive advantage. How can companies give priority to information security and compliance
Reinforcement learning (II): SARS, with code rewriting
Where will Jinan win in hosting the first computing power conference?
SiC Power Semiconductor Industry Summit Forum successfully held
It is found that the data of decimal type in the database can be obtained through resultset.getdouble, but this attribute cannot be obtained through GetObject.
For a safer experience, Microsoft announced the first PC with a secure Pluto chip
【HCIP】两个MGRE网络通过OSPF实现互联(eNSP)