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的更多相关文章

  1. Educational Codeforces Round 68 差G

    Educational Codeforces Round 68 E 题意:有 n 个线段,每个都是平行 x 或者 y 轴,只有互相垂直的两线段才会相交.问形成了多少个矩形. \(n \le 5000, ...

  2. 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 ...

  3. 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. ...

  4. 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 ...

  5. Educational Codeforces Round 66 (Rated for Div. 2)

    A.直接模拟. #include<cstdio> #include<cstring> #include<iostream> #include<algorith ...

  6. 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 < ...

  7. Educational Codeforces Round 63部分题解

    Educational Codeforces Round 63 A 题目大意就不写了. 挺简单的,若果字符本来就单调不降,那么就不需要修改 否则找到第一次下降的位置和前面的换就好了. #include ...

  8. Educational Codeforces Round 81 + Gym 102267

    UPD:变色了!!!历史最高1618~ Educational Codeforces Round 81 (Rated for Div. 2) The 2019 University of Jordan ...

  9. Educational Codeforces Round 20

    Educational Codeforces Round 20  A. Maximal Binary Matrix 直接从上到下从左到右填,注意只剩一个要填的位置的情况 view code //#pr ...

随机推荐

  1. pip2 install protobuf==2.6.1

    [libprotobuf FATAL google/protobuf/stubs/common.cc:61] This program requires version 3.5.0 of the Pr ...

  2. 由于TableView的Section的头部和尾部高度设置的不规范引起的部分Section中的图片无法正常显示

    当tableview的组的头部和尾部的高度设置如下时: -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(N ...

  3. mnist lenet caffe 测试

    # -*- coding: utf-8 -*-import sysimport numpy as npimport structfrom PIL import Imageprint "hel ...

  4. javaScript_BOM浏览器对象模型

    BOM:浏览器对象模型 Browser Object Model 用来访问和操作浏览器窗口,使JavaScript有能力与浏览器对话 通过使用BOM ,可以移动窗口,更改状态栏.执行其他不与页面内容发 ...

  5. ping内网服务器 新

    #!/bin/bash ip="192.168.1."lastip=(200201202210211212220221222) #ip列表 可以继续添加 ps () { ping ...

  6. 7. react 基础 - React Developer Tools 的安装 及 使用

    1. 安装 react 开发调试工具 React Developer Tools 打开 chrome 浏览器访问 chrome://extensions/ 点击右上角的 拓展程序 -> 打开 c ...

  7. .net core excel导入导出

    做的上一个项目用的是vs2013,传统的 Mvc模式开发的,excel报表的导入导出都是那几段代码,已经习惯了. 导入:string filename = ExcelFileUpload.FileNa ...

  8. post表单、json接口

    package com.lv.qggz.man.dhht.api.typesetting; import com.lv.qggz.man.dhht.api.typesetting.vo.UVO;imp ...

  9. CVPR2019 | 超越Mask R-CNN!华科开源图像实例分割新方法MS R-CNN

    安妮 乾明 发自 凹非寺 本文转载自量子位(QbitAI) 实习生又立功了! 这一次,亮出好成绩的实习生来自地平线,是一名华中科技大学的硕士生. 他作为第一作者完成的研究Mask Scoring R- ...

  10. 第一次 C语言课程设计

    小学生测验 最近比较忙,就拿前几天做的课设项目水一水. 内容 面向小学1~2年级学生,随机选择两个整数和加减法形成算式要求学生解答. 功能要求: (1)电脑随机出10道题,每题10分,程序结束时显示学 ...