Educational Codeforces Round 66 差G
Educational Codeforces Round 66
F
题意:长度为 n 的序列,求有多少个区间 \([l,r]\) ,使得其构成了一个 1~r-l+1 的排列。 \(n \le 3*10^5, a_i \le n\)
key:随机权值
合法区间中肯定包含 1 ,并且最大值就是长度。先考虑最大值在 1 的右边的情况,可以枚举每个 1 的右边,记录最大值 x ,此时需要检查 \([r-x+1,r]\) 这个区间是否是一个排列。最大值在 1 左边的情况同理。
考虑 hash :给 1~n 的每个数字一个 64 位的随机权值,定义为 \(h_i\) ,这样一个长度为 k 的排列的 hash 必须是 \(h_1 \ xor \ h_2 \dots \ xor \ h_k\) ,这样就可以 O(1) check 了,所以复杂度是 O(n)。
Educational Codeforces Round 66 差G的更多相关文章
- Educational Codeforces Round 68 差G
Educational Codeforces Round 68 E 题意:有 n 个线段,每个都是平行 x 或者 y 轴,只有互相垂直的两线段才会相交.问形成了多少个矩形. \(n \le 5000, ...
- Educational Codeforces Round 66 (Rated for Div. 2) B. Catch Overflow!
链接:https://codeforces.com/contest/1175/problem/B 题意: You are given a function ff written in some bas ...
- Educational Codeforces Round 66 (Rated for Div. 2) A. From Hero to Zero
链接:https://codeforces.com/contest/1175/problem/A 题意: You are given an integer nn and an integer kk. ...
- Educational Codeforces Round 66 (Rated for Div. 2) A
A. From Hero to Zero 题目链接:http://codeforces.com/contest/1175/problem/A 题目 ou are given an integer n ...
- Educational Codeforces Round 66 (Rated for Div. 2)
A.直接模拟. #include<cstdio> #include<cstring> #include<iostream> #include<algorith ...
- Educational Codeforces Round 39 (Rated for Div. 2) G
Educational Codeforces Round 39 (Rated for Div. 2) G 题意: 给一个序列\(a_i(1 <= a_i <= 10^{9}),2 < ...
- Educational Codeforces Round 63部分题解
Educational Codeforces Round 63 A 题目大意就不写了. 挺简单的,若果字符本来就单调不降,那么就不需要修改 否则找到第一次下降的位置和前面的换就好了. #include ...
- Educational Codeforces Round 81 + Gym 102267
UPD:变色了!!!历史最高1618~ Educational Codeforces Round 81 (Rated for Div. 2) The 2019 University of Jordan ...
- Educational Codeforces Round 20
Educational Codeforces Round 20 A. Maximal Binary Matrix 直接从上到下从左到右填,注意只剩一个要填的位置的情况 view code //#pr ...
随机推荐
- 利用kindlegen实现txt格式小说转换为mobi格式小说(C++实现)
一直以来喜欢在kindle上看小说,kindle不伤眼,也可以帮助控制玩手机的时间.但在kindle上看txt格式的网络小说就很头疼了,这类小说在kindle上是没有目录的,而且篇幅巨长.所以一直以来 ...
- javascript 连续赋值(连等运算)问题研究
前几天看到一个javascript 连续赋值的问题,运行了一下,结果出乎意料,发现这里的水真的有点深啊,连续赋值的底层机制,没有一本前端书籍有详细介绍的,自己做实验研究了一下,先来看结果: var a ...
- 自己整理的常用SQL Server 2005 语句、
--创建数据库 create database 数据库 go --打开数据库 use 数据库 --删除数据库 drop database 数据库 Go --创建数据表 create table 数据表 ...
- c++程序—变量
#include<iostream> using namespace std; int main() { int a = 10; cout << "a=" ...
- Spring的配置文件说明
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.sp ...
- ES6 之 对象的扩展
1.Object.is() 判断俩个值是否相等 +0 不等于 -0 NaN 等于自身 console.log(Object.is('foo','foo')); // true console.log( ...
- JNI传递修改自定义Java Class数组数据
声明:迁移自本人CSDN博客https://blog.csdn.net/u013365635 结合前面讲的2篇关于JNI的文章,这里直接把代码贴上,主要是要知道如果传递自定义Class Array的时 ...
- Codeforces Round #619 (Div. 2)E思维+二维RMQ
题:https://codeforces.com/contest/1301/problem/E 题意:给个n*m的图形,q个询问,每次询问问询问区间最大的合法logo的面积是多少 分析:由于logo是 ...
- B - Given Length and Sum of Digits... CodeForces - 489C (贪心)
You have a positive integer m and a non-negative integer s. Your task is to find the smallest and th ...
- 当初对"软件工程"这个专业的期待和想象是什么?
很多期待,很多幻想 印象很深刻的初中语文老师让我们背诵的一首诗<错误>: <错误> 作 者:郑愁予 我打江南走过 那等在季节里的容颜如莲花的开落 东风不来,三月的柳絮不飞 你底 ...