E. Little Elephant and Shifts time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The Little Elephant has two permutations a and b of length n, consisting of numbers from 1 to n, inclusive. Le…
D. Little Elephant and Array time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output The Little Elephant loves playing with arrays. He has array a, consisting of n positive integers, indexed from…
C. Little Elephant and Problem time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The Little Elephant has got a problem — somebody has been touching his sorted by non-decreasing array a of le…
B. Little Elephant and Numbers time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The Little Elephant loves numbers. He has a positive integer x. The Little Elephant wants to find the number…
A. Little Elephant and Function time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The Little Elephant enjoys recursive functions. This time he enjoys the sorting function. Let a is a permuta…
C. Little Elephant and Shifts Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/problemset/problem/220/C Description The Little Elephant has two permutations a and b of length n, consisting of numbers from 1 to n, inclusive. Let's de…
E - Little Elephant and Shifts 思路: 一次函数线段树(疯狂debug): b不断循环左移,判断每次最小的|i-j|,a[i]=b[j]: 仔细观察发现,每个bi移动时,|i-j|呈现多个一次函数图像: 所以用线段树来维护这些一次函数图像: 线段树维护一次函数,当两个函数在区间没有交点时: 判断哪个在图像较下的位置,然后覆盖: 当有交点时,保留最优,将另一条传下去: 时间复杂度O(nlog^2n); 代码: #include <cmath> #include &l…
二次联通门 : Codeforces 221d D. Little Elephant and Array /* Codeforces 221d D. Little Elephant and Array 题意 : 询问一段区间中出现次数等于自身的数的个数 正解是dp 莫队水过, 作为我莫队的入门题 myj的思路 66 把所有需查询的区间排序 当前查询区间的答案为上一个区间的答案通过多次的区间移动得出 */ #include <algorithm> #include <cstdio>…
ACM思维题训练集合 The Little Elephant has two permutations a and b of length n, consisting of numbers from 1 to n, inclusive. Let's denote the i-th (1 ≤ i ≤ n) element of the permutation a as ai, the j-th (1 ≤ j ≤ n) element of the permutation b - as bj. Th…
Codeforces 204 E 题意:给\(n\)个串,求对于每一个串在至少\(k\)个串中出现的它的子串\(S_{l..r}\)有多少个. 思路:后缀自动机上\(dp\)... 我们首先构造出这\(n\)个串的后缀自动机,其中需要注意将某个串的构建完了后直接将\(lst\)指针赋为\(root\),那么就可以包含这些串的所有子串并且不会有问题. 然后我们就考虑如何来算出某一个子串在\(n\)个串中出现了多少次. 假设现在我们从\(S_i\)的开头走到第\(j\)位,走到了节点\(u\),那么…