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 ...
随机推荐
- leetcode - 两数之和Ⅳ 输入BST(653)
题目描述:给定一个二叉搜索树和一个目标结果,如果 BST 中存在两个元素且它们的和等于给定的目标结果,则返回 true. 解题思路:根据二叉搜索树的特点,对二叉搜索树进行中序遍历可以得到一个从小到达排 ...
- 实验吧web-难-认真一点!(布尔盲注,py脚本)
也可用bp进行爆破,这里用py脚本. 打看网页输入1,显示You are in,输入2,显示You are not in,是个布尔注入. 然后看看过滤了什么. sql注入没有过滤:--+.or sql ...
- 吴裕雄--天生自然TensorFlow2教程:数据加载
import tensorflow as tf from tensorflow import keras # train: 60k | test: 10k (x, y), (x_test, y_tes ...
- Java基础——HashTable源码分析
HashTable是基于哈希表的Map接口的同步实现 HashTable中元素的key是唯一的,value值可重复 HashTable中元素的key和value不允许为null,如果遇到null,则返 ...
- @EnableAutoConfiguration激活自动装配
给予上个例子,将WebConfiguration类上的@SpringBootApplication换成@EnableAutoConfiguration.启动并运行http://localhost:80 ...
- JetBrains,vim配置文件, .ideavimrc
addr: https://github.com/NorseLZJ/lzj-config/tree/master/idea_vim
- psp --2
PSP0 ---2 项目计划日志 姓名:赵腾 日期:9/12/2017 任务 日期 听课 编写程序 阅读课 ...
- 使用java service wrapper将java程序注册为window服务
1.下载java service wrapper 下载地址:http://wrapper.tanukisoftware.com/doc/english/download.jsp 针对自己的需求下载相应 ...
- eclipse上部署到tomcat不能自动部署maven管理的额jar包
- Redis主从复制以及主从复制原理
Redis 是一个开源的使用 ANSI C 语言编写.支持网络.可基于内存亦可持久化的日志型.Key-Value 数据库,并提供多种语言的 API.从 2010年 3 月 15 日起,Redis 的开 ...