CF1110E Magic Stones(构造题)】的更多相关文章

这场CF怎么这么多构造题…… 题目链接:CF原网 洛谷 题目大意:给定两个长度为 $n$ 的序列 $c$ 和 $t$.每次我们可以对 $c_i(2\le i<n)$ 进行一次操作,也就是把 $c_i$ 变成 $c_i'=c_{i-1}+c_{i+1}-c_i$.问 $c$ 能否在若干次操作后变成 $t$. $1\le n\le 10^5,1\le c_i,t_i\le 2\times 10^9$. 很容易考虑差分.我们设 $d_i=c_i-c_{i-1},s_i=t_i-t_{i-1}(2\le…
传送门 将原数组差分一下,设\(d_i = c_{i+1} - c_i\) 考虑在\(i\)位置的一次操作会如何影响差分数组 \(d_{i+1}' = c_{i+1} - (c_{i+1} + c_{i-1} - c_i) = c_i - c_{i-1} = d_i\) \(d_i' = (c_{i+1} + c_{i-1} - c_i) - c_{i-1} = c_{i+1} - c_i = d_{i+1}\) 所以本质上一次操作交换了差分数组中的两个元素 所以只需要判断差分数组中的每一个元素…
题目大意:有一个长度为$n(n\leqslant10^5)$的数列$c$,问是否可以经过若干次变换变成数列$t$,一次变换为$c'_i=c_{i+1}+c_{i-1}-c_i$ 题解:思考一次变换的本质,对$c$做差分,原差分为$c_i-c_{i-1},c_{i+1},c_i$:对$c_i$做一次变换后为:$c'_i-c_{i-1}=c_{i+1}+c_{i-1}-c_i-c_{i-1}=c_{i+1}-c_i,c_{i+1}-c'_i=c_{i+1}-(c_{i+1}+c_{i-1}-c_i)…
题面 Grigory has n n magic stones, conveniently numbered from \(1\) to \(n\). The charge of the \(i\)-th stone is equal to \(c_i\). Sometimes Grigory gets bored and selects some inner stone (that is, some stone with index \(i\), where \(2 \le i \le n-1…
E. Magic Stones time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Grigory has nn magic stones, conveniently numbered from 11 to nn . The charge of the ii -th stone is equal to cici . Sometime…
C. Devu and Partitioning of the Array time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Devu being a small kid, likes to play a lot, but he only likes to play with arrays. While playing he ca…
link:http://acm.hdu.edu.cn/showproblem.php?pid=4671 其实是不难的那种构造题,先排第一列,第二列从后往前选. #include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <cctype> #include <algorithm> #…
D. Optimal Number Permutation 题目连接: http://www.codeforces.com/contest/622/problem/D Description You have array a that contains all integers from 1 to n twice. You can arbitrary permute any numbers in a. Let number i be in positions xi, yi (xi < yi) i…
这是一道蛮基础的构造题. - k         +(k - 1)      -(k - 2) 1 + k ,    1 ,         k ,             2,    ................... \  /        \  /           \  / k          k-1          k-2 如图所示,先构造第一个数,就是1 + k, 然后接下来每个数字和上个数相差k , k -1 , k -2 这样下来,最后一个数字就是一个中间的数字,过程就…
3097: Hash Killer I Time Limit: 5 Sec  Memory Limit: 128 MBSec  Special JudgeSubmit: 963  Solved: 364[Submit][Status][Discuss] Description 这天天气不错,hzhwcmhf神犇给VFleaKing出了一道题: 给你一个长度为N的字符串S,求有多少个不同的长度为L的子串. 子串的定义是S[l].S[l + 1].... S[r]这样连续的一段. 两个字符串被认为是…