1000w的数组,一开始都是2^31-1,然后经过5*10^7次随机位置的随机修改,问你每次的全局最小值。

有效的随机修改的期望次数很少,只有当修改到的位置恰好是当前最小值的位置时才需要扫一下更新最小值。

分个块或者直接暴力都可以。

#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int sz,l[10005],r[10005],sum,num[10000005];
unsigned int x0,x1,a,b,c,A[10000005],minv[10005];
unsigned int next() {
unsigned int t = x0 * a + x1 * b + c;
x0 = x1;
x1 = t;
return x0 >> 2;
}
int n,q;
int main(){
// freopen("i.in","r",stdin);
cin>>n>>q>>x0>>x1>>a>>b>>c;
for(int i=1;i<=n;++i){
A[i]=((unsigned int)1<<31)-1;
}
sz=sqrt(n);
for(sum=1;sum*sz<n;sum++)
{
l[sum]=(sum-1)*sz+1;
r[sum]=sum*sz;
for(int i=l[sum];i<=r[sum];i++)
num[i]=sum;
}
l[sum]=sz*(sum-1)+1;
r[sum]=n;
for(int i=l[sum];i<=r[sum];i++)
num[i]=sum;
for(int i=1;i<=sum;++i){
minv[i]=((unsigned int)1<<31)-1;
}
unsigned int nowans=((unsigned int)1<<31)-1;
unsigned int base=1;
unsigned int ans=0;
for(int i=1;i<=q;++i){
base*=(unsigned)10099;
unsigned int p=next()%(unsigned int)n;
unsigned int former=A[p+1];
A[p+1]=next();
int t=num[p+1];
if(former==minv[t]){
minv[t]=((unsigned int)1<<31)-1;
for(int i=l[t];i<=r[t];++i){
minv[t]=min(minv[t],A[i]);
}
}
else if(A[p+1]<minv[t]){
minv[t]=A[p+1];
}
if(former==nowans){
nowans=((unsigned int)1<<31)-1;
for(int i=1;i<=sum;++i){
nowans=min(nowans,minv[i]);
}
}
else if(A[p+1]<nowans){
nowans=A[p+1];
}
ans+=nowans*base;
}
cout<<ans<<endl;
return 0;
}

【分块】【暴力】XVII Open Cup named after E.V. Pankratiev Grand Prix of Moscow Workshops, Sunday, April 23, 2017 Problem I. Rage Minimum Query的更多相关文章

  1. XVII Open Cup named after E.V. Pankratiev Grand Prix of Moscow Workshops, Sunday, April 23, 2017 Problem D. Great Again

    题目: Problem D. Great AgainInput file: standard inputOutput file: standard outputTime limit: 2 second ...

  2. XVII Open Cup named after E.V. Pankratiev Grand Prix of Moscow Workshops, Sunday, April 23, 2017 Problem K. Piecemaking

    题目:Problem K. PiecemakingInput file: standard inputOutput file: standard outputTime limit: 1 secondM ...

  3. XVII Open Cup named after E.V. Pankratiev. Grand Prix of America (NAIPC-2017)

    A. Pieces of Parentheses 将括号串排序,先处理会使左括号数增加的串,这里面先处理减少的值少的串:再处理会使左括号数减少的串,这里面先处理差值较大的串.确定顺序之后就可以DP了. ...

  4. XVIII Open Cup named after E.V. Pankratiev. Grand Prix of Khamovniki Problem J Stairways解题报告(分块+维护凸壳)

    首先ORZ一发Claris聚聚的题解:http://www.cnblogs.com/clrs97/p/8689215.html,不然我可能没机会补过这道神题了. 这里写一个更详细的题解吧(我还是太菜了 ...

  5. XVIII Open Cup named after E.V. Pankratiev. Grand Prix of SPb

    A. Base $i - 1$ Notation 两个性质: $2=1100$ $122=0$ 利用这两条性质实现高精度加法即可. 时间复杂度$O(n)$. #include<stdio.h&g ...

  6. XVIII Open Cup named after E.V. Pankratiev. Grand Prix of Siberia

    1. GUI 按题意判断即可. #include<stdio.h> #include<iostream> #include<string.h> #include&l ...

  7. XVIII Open Cup named after E.V. Pankratiev. Grand Prix of Peterhof

    A. City Wall 找规律. #include<stdio.h> #include<iostream> #include<string.h> #include ...

  8. XVIII Open Cup named after E.V. Pankratiev. Grand Prix of Khamovniki

    A. Ability Draft 记忆化搜索. #include<stdio.h> #include<iostream> #include<string.h> #i ...

  9. XVIII Open Cup named after E.V. Pankratiev. Grand Prix of Korea

    A. Donut 扫描线+线段树. #include<cstdio> #include<algorithm> using namespace std; typedef long ...

随机推荐

  1. chrome最小字体12px如何修改

    在html标记样式里加入 <style> html { -webkit-text-size-adjust:none } </style> 这样的方式可以设置chrome字体小于 ...

  2. jqgrid 翻页记录选中行

    简单的jqgrid列表 $("#list").jqGrid({ url:contextPath + "/getList", postData: data, da ...

  3. HTML/CSS/JS编码规范

    最近整理了一份HTML/CSS/JS编码规范,供大家参考.目录:一.HTML编码规范二.CSS编码规范三.JS编码规范 一.HTML编码规范 1. img标签要写alt属性 根据W3C标准,img标签 ...

  4. PHP路由代码

    <?php /**  * 路由  * @author 角度 QQ:1286522207  *  */ class Dispatcher extends Action {     private ...

  5. 【bzoj4552】排序

    二分一个值,然后线段树上模拟. #include<bits/stdc++.h> #define lson (o<<1) #define rson (o<<1|1) ...

  6. Educational Codeforces Round 26 F. Prefix Sums 二分,组合数

    题目链接:http://codeforces.com/contest/837/problem/F 题意:如题QAQ 解法:参考题解博客:http://www.cnblogs.com/FxxL/p/72 ...

  7. mac cocoapod安装过程

    cocoapod: 自动化管理第三方开发包的一个插件, 废话不多说, 一个新手只需做如下几个步骤 1-> 安装ruby环境(可忽略, 不是必要) 1.1 首先我们先看看当前你机器上ruby的版本 ...

  8. vue页面高度填充,不出现滚动条

    现在的需求是这样:vue单页工程化开发,上面有一个header,左边有一个侧边栏,右边内容展示.要求左边侧边栏的高度,要填充满整个页面(除了header外,header:height:60px)--如 ...

  9. linux命令(20):rm命令

    1. 强行删除文件,系统不再确认:rm –f test.log 2. 删除任何.log文件:rm *.log 3. 将test子目录及子目录中所有档案删除:rm –r  test 4. 将 test子 ...

  10. AC日记——[ZJOI2012]网络 bzoj 2816

    2816 思路: 多个LCT: 代码: #include <bits/stdc++.h> using namespace std; #define maxn 10005 #define l ...