CF455D. Serega and Fun】的更多相关文章

D. Serega and Fun time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output Serega loves fun. However, everyone has fun in the unique manner. Serega has fun by solving query problems. One day Fedor…
D. Serega and Fun Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/455/problem/D Description Serega loves fun. However, everyone has fun in the unique manner. Serega has fun by solving query problems. One day Fedor came up w…
Serega and Fun 题意: [l,r]循环右移一位,查询区间内某个数出现次数 为什么好多人用链表?反正我是不会写双向链表 完全可以分块然后模拟啊...中间的块只会插入删除一个元素呀....用deque就好了 虽然说deque常数大但是CF上标准库快啊 不用deque怎么做?可以每个块开一个$O(S)$大小的数组,然后每$S$个操作重建一次 一个非常奇怪的事情是$S=n^0.618$比$n^0.5$快了4倍多...300多ms #include <iostream> #include…
D. Serega and Fun time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output Serega loves fun. However, everyone has fun in the unique manner. Serega has fun by solving query problems. One day Fedor…
大意:给定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…
https://codeforces.com/problemset/problem/455/D 其实方法很多,然而当初一个也想不到... 1.分块,块内用链表维护 修改[l,r]就当成删除第r个元素,在第l个元素之前插入删掉的元素:就找到r删除,然后调整各个块的结构(对于[block[l]+1,block[r]]中的每个块,把它之前一块的最后一个元素移到自身块的第一个元素),然后找到l应该插入的位置并插入l 修改的同时,维护一下各个块中各个元素出现的次数 查询应该没什么问题了... #inclu…
 Phone Numbers Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 151B Description Winters are just damn freezing cold in Nvodsk! That's why a group of n friends prefers to take a taxi, ord…
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…
1. CF 438D The Child and Sequence 大意: n元素序列, m个操作: 1,询问区间和. 2,区间对m取模. 3,单点修改 维护最大值, 取模时暴力对所有>m的数取模. 因为取模后至少减半, 复杂度$O(nlognlogC)$ 2. CF 431E Chemistry Experiment 大意: n个试管, 第$i$个试管有$a_i$单位水银, m个操作: 1, 修改$a_x$改为$v$. 2, 将$v$单位水倒入试管, 求一种方案使得有水的试管水银与水总量的最大…