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 ...
随机推荐
- 转:JS高级学习笔记(8)- JavaScript执行上下文和执行栈
必看参考: 请移步:博客园 JavaScript的执行上下文 深入理解JavaScript执行上下文和执行栈 JavaScript 深入之执行上下文 写在开头 入坑前端已经 13 个月了,不能再称自己 ...
- OC项目加入swift第三方库遇到的坑
https://www.jianshu.com/p/96d868dcd69c 2017.07.07 16:23* 字数 295 阅读 5218评论 2喜欢 4 首先,在OC项目的Podfile文件中添 ...
- 201903-2 二十四点 Java
思路: 数据结构中,栈可以解决运算的问题.利用压栈和弹栈操作实现(这里用队列模拟).具体的: 遇到乘除号,弹出栈顶元素,将计算结果压入栈中.遇到加减号,将后面的数一起压入栈中. 注意: substri ...
- Spring Boot without the web server
https://stackoverflow.com/questions/26105061/spring-boot-without-the-web-server/28565277 1. spring.m ...
- [安洵杯 2019]easy_serialize_php
0x00 知识点 PHP反序列化的对象逃逸 任何具有一定结构的数据,只要经过了某些处理而把自身结构改变,则可能会产生漏洞. 参考链接: https://blog.csdn.net/a3320315/a ...
- HyperLedger Cello学习笔记
HyperLedger Cello学习笔记 转载请注明出处:HyperLedger Cello学习笔记 概述 Hyperledger Cello是Hyperledger下的一个子项目,其主要功能如下: ...
- 【JavaScript】回流(reflow)与重绘(repaint)
重绘与回流 首先要了解页面是如何呈现的: HTML文档加载后生成DOM树(包括display:none;元素): 在DOM树的基础上配合css样式结构体生成render树(不包含display:non ...
- .NET CORE 配置Swagger文档
1.先通过NuGet安装Swashbuckle.AspNetCore ,支持.NET core,版本是4.0.1,以上版本好像有些功能不支持 2.startup文件里注入swagger,Configu ...
- NSDictionary和NSMaptable, NSArray,NSSet,NSOrderedSet和NSHashTable的区别
NSSet, NSDictionary, NSArray是Foundation框架关于集合操作的常用类, 和其他标准的集合操作库不同, 他们的实现方法对开发者进行隐藏, 只允许开发者写一些简单的代码, ...
- SDWebImage清理缓存
[[SDImageCache sharedImageCache] getSize]//计算缓存的大小,单位B float tmpSize = [[SDImageCache sharedImageCac ...