CodeForces - 455D】的更多相关文章

题目链接:http://codeforces.com/problemset/problem/455/D 题意:给定一个长度为n的序列a[]. m次操作.共有两种操作 1 l r:将序列的a[l].a[l+1]...a[r]变成a[r].a[l].a[l+1]...a[r-1]:2 l r k:求序列a[l].a[l+1]...a[r]中有多少个值为k. 输入的l,r,k都是加密过的.所以要解密一下.规则为 l=(l+ans-1)%n+1  r=(r+ans-1)%n+1 k=(k+ans-1)%…
https://codeforces.com/problemset/problem/455/D 其实方法很多,然而当初一个也想不到... 1.分块,块内用链表维护 修改[l,r]就当成删除第r个元素,在第l个元素之前插入删掉的元素:就找到r删除,然后调整各个块的结构(对于[block[l]+1,block[r]]中的每个块,把它之前一块的最后一个元素移到自身块的第一个元素),然后找到l应该插入的位置并插入l 修改的同时,维护一下各个块中各个元素出现的次数 查询应该没什么问题了... #inclu…
Serega loves fun. However, everyone has fun in the unique manner. Serega has fun by solving query problems. One day Fedor came up with such a problem. You are given an array a consisting of n positive integers and queries to it. The queries can be of…
大意:给定n元素序列, 2种操作 将区间$[l,r]$循环右移1位 询问$[l,r]$中有多少个等于k的元素 现在给定q个操作, 输出操作2的询问结果, 强制在线 思路1: 分块 每个块内维护一个链表, 循环右移相当于删除一个元素, 再插入一个元素, 每个块内再维护一个桶统计元素个数即可 分块好久没写过了, 先放个分块大致流程 void init() { //sqn是分块数, blo[i]是位置i所属块的编号 //L[i], R[i]是位置i所属块的左右边界 sqn = sqrt(n); REP…
题意: 给定一个长度为 N 的序列两种操作1 l r 将[l,r]的数向右循环移位 2 l r 询问[l,r]内有多少个数等于 k其中 N,Q≤105,ai≤N 强制在线 思路: 1. 每块用一个链表维护一下 位移的话由于是链表,操作速度很快然后每个数都不超过 N,所以用一个数组记录一下每块每个数的个数 总的复杂度就是 O(Qsqrt(N)) 2. 如果不考虑那个奇怪的询问的话,可以简单地用splay树维护序列.但是splay上显然不能维护每种颜色的个数,这样在每个节点上时间和空间都是O(n)的…
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题.. 今天,我们来扒一下cf的题面! PS:本代码不是我原创 1. 必要的分析 1.1 页面的获取 一般情况CF的每一个 contest 是这样的: 对应的URL是:http://codeforces.com/contest/xxx 还有一个Complete problemset页面,它是这样的:…
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships consists of bconsecutive cells. No cell can be part of two ships, however, the shi…
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t minutes. There is a straight road of length s from the service to the cinema. Let's…
http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interview down without punctuation marks and spaces to save time. Thus, the interview is now a string s consisting of n lowercase English letters. There is…
http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概率是在正面,各个卡牌独立.求把所有卡牌来玩Nim游戏,先手必胜的概率. (⊙o⊙)-由于本人只会在word文档里写公式,所以本博客是图片格式的. Code #include <cstdio> #include <cstring> #include <algorithm> u…