CF798E. Mike and code of a permutation 题意: 排列p,编码了一个序列a.对于每个i,找到第一个\(p_j > p_i\)并且未被标记的j,标记这个j并\(a[i]=j\).给出a求一个可行的p,保证有解.\(n \le 500000\) 官方题解很详细 令\(b(i) = a^{-1}(i)\),也就是说\(b_i\)表示i被谁标记了 容易想到把小于关系用边表示然后拓扑排序 将没有的a和b置为n+1 我们从题目中能直接得到两种小于关系:\((i,b_i)\…
先考虑80分做法,即满足A串长度均不小于B串,容易发现每个B串对应的所有A串在后缀数组上都是一段连续区间,线段树优化连边然后判环求最长链即可.场上就写了这个. 100分也没有什么本质区别,没有A串长度不小于B串的性质后,区间连边变成了矩形连边,用主席树或KDTree优化连边即可,当然主席树会更靠谱,这里写了KDTree,在loj上T掉了. #include<bits/stdc++.h> using namespace std; #define ll long long #define N 20…
Toposort Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 499 Accepted Submission(s): 203 Problem Description There is a directed acyclic graph with n vertices and m edges. You are allowed…
DZY Loves Topological Sorting Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 1250 Accepted Submission(s): 403 Problem Description A topological sort or topological ordering of a directed g…
[Educational Codeforces Round 81 (Rated for Div. 2)]E. Permutation Separation(线段树,思维,前缀和) E. Permutation Separation time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given a permutat…
3832: [Poi2014]Rally Time Limit: 20 Sec Memory Limit: 128 MBSec Special JudgeSubmit: 168 Solved: 84[Submit][Status][Discuss] Description An annual bicycle rally will soon begin in Byteburg. The bikers of Byteburg are natural long distance cyclists…