首页 > 其他分享 >ARC114F Permutation Division

ARC114F Permutation Division

时间:2023-06-17 09:01:09浏览次数:39  
标签:Division le 前缀 ARC114F 开头 Permutation Bob 最长 字典

题意

给定一个 \(1 \sim N\) 的排列,Alice 把它划分成 \(k\) 段,Bob 把这 \(k\) 段任意排列。Alice 想让字典序最小,Bob 想让字典序最大。请问最后的排列。

数据范围: \(1\le k\le N\le 2 \times 10^5\)。

题解

首先 Bob 的排序只取决于每个段第一个数的大小。字典序不会变小,所以考虑最大化最长公共前缀长度。假设公共前缀长度为某个数是合法的,那么需要满足前面的划分是一个下降子序列,并且后面不能有比最后一个段的开头还大的数作为段落开头。那么考虑枚举最后一个段的开头 \(x\),计算一下前面包含序列第一个数的最长下降子序列长度,可以计算出后面至少要划分出 \(t\) 段,于是可以二分出一个位置使得这个位置后面恰好有 \(t\) 个小于 \(x\) 的元素。那么这个位置前面就是最长公共前缀。找到最长公共前缀长度以后,后面刚好有 \(t\) 个元素可以作为开头,按照他们划分段,然后排序即可。

标签:Division,le,前缀,ARC114F,开头,Permutation,Bob,最长,字典
From: https://www.cnblogs.com/kyeecccccc/p/17487003.html

相关文章

  • AtCoder Regular Contest 141 C Bracket and Permutation
    洛谷传送门AtCoder传送门考虑给出\(S\),如何求\(P,Q\)。先考虑\(P\),那我们肯定想让\(P\)的每一项都尽量往前靠。设\([1,k]\)为合法括号串,\(S_{k+1}=\texttt{)}\),那\(P\)的前\(k\)项依次为\(1\simk\),第\(k+1\)项不能为\(k+1\)了,那找到\(k+1\)之......
  • Educational Codeforces Round 7-D. Optimal Number Permutation
    原题链接D.OptimalNumberPermutationtimelimitpertestmemorylimitpertestinputoutputYouhavearray a thatcontainsallintegersfrom 1 to n twice.Youcanarbi......
  • AtCoder Beginner Contest 214 G Three Permutations
    洛谷传送门AtCoder传送门比较平凡的一个容斥。考虑把问题转化成,求\(\foralli\in[1,n],r_i\nei\landr_i\nep_i\)的\(r\)方案数。考虑到不弱于错排,所以容斥。设钦定\(i\)个\(r_i\)取了\(i,p_i\)中的一个的方案数为\(f_i\),其余任意,那么:\[ans=\sum\limi......
  • next_permutation函数
    next_permutation的函数声明:#include <algorithm> boolnext_permutation(iteratorstart,iteratorend);next_permutation函数的返回值是布尔类型,在STL中还有perv_permutation()函数 #include<iostream>#include<algorithm>#include<string>usingnamespacest......
  • Permutation Invariant Graph Generation via Score-Based Generative Modeling
    目录概符号说明本文方法代码NiuC.,SongY.,SongJ.,ZhaoS.,GroverA.andErmonS.Permutationinvariantgraphgenerationviascore-basedgenerativemodeling.AISTATS,2020.概本文利用diffusion进行图的生成,很朴素.符号说明\(\mathbf{A}^{\pi}\),邻接......
  • SP15637 Mr Youngs Picture Permutations 题解
    题意给定一个最多有\(5\)排的一个队伍,每一个位置对应一个同学,给定总人数和第\(i\)排要站\(n_i\)个人。要求每行左边的同学身高要大于右边的,每列从上往下要从大到小。问:满足要求的一共有多少种方案。思路DP首先考虑,在这个题目中,有用的状态有每列最后的人的高度,每行......
  • TheForces Round #13 (Boombastic-Forces) G. Permutation Removal
    感觉好久没有写过这样单独一篇题目的博客了的说昨天上大物课的时候ztc问了我这道题,然后我口胡了下感觉还挺有趣的不过其它题目就没啥时间看了,正巧最近在练DP专题,就顺手记录一下吧这题的数据范围和问题一眼区间DP的形式,直接设\(f_{l,r}\)表示区间\([l,r]\)的答案刚开始naive地......
  • 【Introductory Biology】Lecture 12 - Chemical Genetics 1 - Cell Division & Segre
    文章目录SlidesRefSlidescentraldogma中心法则…Andwe’regoingtostarttalkingabouthowinformationflowsbetweencells,sofromaparentcelltoitsdaughtercells.Andwe’realsogonnatalkabouthowinformationflowsfromgenerationtothenext.Andth......
  • D. Super-Permutation
    D.Super-PermutationApermutationisasequence$n$integers,whereeachintegerfrom$1$to$n$appearsexactlyonce.Forexample,$[1]$,$[3,5,2,1,4]$,$[1,3,2]$arepermutations,while$[2,3,2]$,$[4,3,1]$,$[0]$arenot.Givenapermutation$a$,wec......
  • 2014 Pacific Northwest Region Programming Contest—Division 2 Problem U — lim
    Incollegefootball,manydifferentsourcescreatealistoftheTop25teamsinthecountry.Sinceit’ssubjective,theselistsoftendiffer,butthey’reusuallyverysimilar.Yourjobistocomparetwooftheselists,anddeterminewheretheyaresimi......