CodeForces 811B Vladik and Complicated Book】的更多相关文章

离线,树状数组. 数据范围好像有点小,直接暴力可以过的. 我直接上了$n,Q≤100000$的做法:只需要判断区间上比$x$小的数字有几个即可,可以对询问进行离线操作,从左到右一个一个数字插入到树状数组中. #include <iostream> #include <cstdio> #include <cstring> #include <string> #include <algorithm> #include <vector> #…
B. Vladik and Complicated Book time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Vladik had started reading a complicated book about algorithms containing n pages. To improve understanding o…
B. Vladik and Complicated Book   time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Vladik had started reading a complicated book about algorithms containing n pages. To improve understanding…
codeforces 811E Vladik and Entertaining Flags 题面 \(n*m(1<=n<=10, 1<=m<=1e5)\)的棋盘,每个格子有一个值. 定义联通块:联通块中所有格子的值相等,并且格子四联通. \(1e5\)次询问,每次询问子矩形\((1, l, n, r)\)中联通块的数量. 题解 线段树区间合并. \(cnt[rt]\):区间中联通块个数 \(pre[rt][]\):在区间中用并查集维护端点的连通性.在给合并之后的集合重新编号时,要注…
Vladik had started reading a complicated book about algorithms containing n pages. To improve understanding of what is written, his friends advised him to read pages in some order given by permutation P = [p1, p2, ..., pn], where pi denotes the numbe…
Codeforces Round #384 (Div. 2) 题目链接:Vladik and fractions Vladik and Chloe decided to determine who of them is better at math. Vladik claimed that for any positive integer \(n\) he can represent fraction \(\frac{2}{n}\) as a sum of three distinct posi…
http://codeforces.com/contest/811/problem/C [题意] 给定一个自然数序列,在这个序列中找出几个不相交段,使得每个段的异或值之和相加最大. 段的异或值这样定义:段中每个不同数字(不重复)相异或. 段有这样的要求:段中任意一个数字不会在段外出现. [思路] 首先预处理每个数字第一次出现和最后一次出现的位置,这样对于一个区间[l,r]就很容易判断是否为满足题意的段. 然后区间DP,dp[i]表示子序列[1,i]的最大值. 状态转移:对于dp[i],最小值为d…
C. Vladik and Memorable Trip time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Vladik often travels by trains. He remembered some of his trips especially well and I would like to tell you ab…
http://codeforces.com/problemset/problem/811/B 题意: 给定一个长度为 N 不重复的数字序列,然后对其进行 M 次询问. 每次询问含L,R,X三个值,问如果数字序列中的 L ~ R 位置范围内进行从小到大的排序后,原本位置为 X 的数字是否变了. 由于 N 和 M 的范围都很小(10000),甚至不用模拟排序,对于每次询问直接 L ~ R 过一遍看有多少个元素小于 X 位置的那个,如果这个计数正好等于 X-L,那么位置为 X 的那个元素自然不会变.…
题意:给定n,求三个不同的数满足,2/n = 1/x + 1/y + 1/z. 析:首先1是没有解的,然后其他解都可以这样来表示 1/n, 1/(n+1), 1/(n*(n+1)),这三个解. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib> #include <…