[CF551E]GukiZ and GukiZiana】的更多相关文章

题目大意:一个长度为$n(n\leqslant5\times10^5)$的数组,有两个操作: $1\;l\;r\;x:$把区间$[l,r]$加上$x$ $2\;x:$询问$x$第一次出现和最后一次出现之间的距离,若没出现输出$-1$ 题解:分块,把每个块排个序(可以把数值为第一关键字,位置为第二关键字),整块的加就块上打$tag$,非整块的就暴力重构,查询就在每个块内求这个数出现位置,直接二分查找就行了.设块大小为$S$,修改复杂度$O(\dfrac n S+2S)$,查询复杂度$O(\dfra…
E. GukiZ and GukiZiana Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/551/problem/E Description Professor GukiZ was playing with arrays again and accidentally discovered new function, which he called GukiZiana. For given a…
Problem E. GukiZ and GukiZiana Solution: 先分成N=sqrt(n)块,然后对这N块进行排序. 利用二分查找确定最前面和最后面的位置. #include <bits/stdc++.h> using namespace std; typedef long long ll; vector<]; ll add[], a[], pos[]; ll n, q, bk, N; bool cmp( int x, int y ) { if( a[x] == a[y]…
GukiZ and GukiZiana 题意: 区间加 给出$y$查询$a_i=a_j=y$的$j-i$最大值 一开始以为和论文CC题一样...然后发现他带修改并且是给定了值 这样就更简单了.... 每个块维护排好序的结果 修改暴力重构+整块打标记 查询暴力查+整块二分找数量 复杂度$O(SlogS + \frac{N}{S} + S+\frac{N}{S}logS)$ woc求了一节课导数也没求出最值来又发现一开始式子列错了不管了我就开根号了..(我才不会说是因为乱搞了一下更慢了) 貌似是因为…
E - GukiZ and GukiZiana 思路:分块, 块内二分 代码: #pragma GCC optimize(2) #pragma GCC optimize(3) #pragma GCC optimize(4) #include<bits/stdc++.h> using namespace std; #define fi first #define se second #define pi acos(-1.0) #define LL long long //#define mp m…
E. GukiZ and GukiZiana time limit per test 10 seconds memory limit per test 256 megabytes input standard input output standard output Professor GukiZ was playing with arrays again and accidentally discovered new function, which he called GukiZiana. F…
题目链接 GukiZ and GukiZiana 题目大意:一个数列,支持两个操作.一种是对区间$[l, r]$中的数全部加上$k$,另一种是查询数列中值为$x$的下标的最大值减最小值. $n <= 500000, q <= 50000$ 我一开始的反应是线段树,然后发现自己完全想错了…… 这道题时限$10$秒,但也很容易超时.我后来是用分块过的. 把序列分成$\sqrt{n}$个块,每个块的大小为$\sqrt{n}$(最后一个块可能因为不能整除的关系可能会小一些) 每个块维护一个值$delt…
[codeforces551E]GukiZ and GukiZiana 试题描述 Professor GukiZ was playing with arrays again and accidentally discovered new function, which he called GukiZiana. For given array a, indexed with integers from 1 to n, and number y, GukiZiana(a, y) represents…
GukiZ and GukiZiana Time Limit: 10000ms Memory Limit: 262144KB This problem will be judged on CodeForces. Original ID: 551E64-bit integer IO format: %I64d      Java class name: (Any)   Professor GukiZ was playing with arrays again and accidentally di…
time limit per test 10 seconds memory limit per test 256 megabytes input standard input output standard output Professor GukiZ was playing with arrays again and accidentally discovered new function, which he called GukiZiana. For given array a, index…