hdu6356 Glad You Came 杭电多校第五场 RMQ ST表(模板)
Glad You Came
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 1489 Accepted Submission(s): 629
In order to avoid huge input data, these operations are encrypted through some particular approach.
There are three unsigned 32-bit integers X,Y and Z which have initial values given by the input. A random number generator function is described as following, where ∧ means the bitwise exclusive-OR operator, << means the bitwise left shift operator and >> means the bitwise right shift operator. Note that function would change the values of X,Y and Z after calling.

Let the i-th result value of calling the above function as fi (i=1,2,⋯,3m). The i-th operation of Steve is to update aj as vi if aj<vi (j=li,li+1,⋯,ri), where
Each of the following T lines describes a test case and contains five space-separated integers n,m,X,Y and Z.
1≤T≤100, 1≤n≤105, 1≤m≤5⋅106, 0≤X,Y,Z<230.
It is guaranteed that the sum of n in all the test cases does not exceed 106 and the sum of m in all the test cases does not exceed 5⋅107.
1 10 100 1000 10000
10 100 1000 10000 100000
100 1000 10000 100000 1000000
1000 10000 100000 1000000 10000000
1446334207
351511856
47320301347
In the first sample, a = [1031463378] after all the operations.
In the second sample, a = [1036205629, 1064909195, 1044643689, 1062944339, 1062944339, 1062944339, 1062944339, 1057472915, 1057472915, 1030626924] after all the operations.
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <queue>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <algorithm>
#define ls (r<<1)
#define rs (r<<1|1)
#define debug(a) cout << #a << " " << a << endl
using namespace std;
typedef long long ll;
const ll maxn = 1e5+10;
const ll mod = 998244353;
const double pi = acos(-1.0);
const double eps = 1e-8;
unsigned x, y, z;
unsigned rng() {
x ^= x << 11;
x ^= x >> 4;
x ^= x << 5;
x ^= x >> 14;
unsigned w = x^(y^z);
x = y;
y = z;
z = w;
return z;
}
ll n, m, a[maxn], st[maxn][20], Log[maxn];
void update( ll le, ll ri, ll z ) { //维护(le,ri)区间最大值
ll k = Log[ri-le+1];
st[le][k] = max(st[le][k],z);
st[ri-(1<<k)+1][k] = max(st[ri-(1<<k)+1][k],z);
} int main() {
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
Log[2] = 1;
for( ll i = 3; i < maxn; i ++ ) { //预处理区间所有log2()的值,节省时间
Log[i] = Log[i>>1]+1;
}
ll T;
cin >> T;
while( T -- ) {
cin >> n >> m >> x >> y >> z;
for( ll i = 1; i <= n; i ++ ) { //n最大的情况下,log2(maxn) = 16
for( ll j = 0; j < 18; j ++ ) {
st[i][j] = 0;
}
}
for( ll i = 1; i <= m; i ++ ) {
ll x = rng()%n+1, y = rng()%n+1, z = rng()%(1<<30);
update(min(x,y),max(x,y),z);
}
for( ll j = 17; j; j -- ) { //反向一遍st求出每一个数的最大值
for( ll i = 1; i+(1<<j)-1 <= n; i ++ ) {
st[i][j-1] = max(st[i][j-1],st[i][j]);
st[i+(1<<(j-1))][j-1] = max(st[i+(1<<(j-1))][j-1],st[i][j]);
}
}
ll ans = 0;
for( ll i = 1; i <= n; i ++ ) {
ans = ans^(i*st[i][0]);
}
cout << ans << endl;
}
return 0;
}
hdu6356 Glad You Came 杭电多校第五场 RMQ ST表(模板)的更多相关文章
- 2018杭电多校第五场1002(暴力DFS【数位】,剪枝)
//never use translation#include<bits/stdc++.h>using namespace std;int k;char a[20];//储存每个数的数值i ...
- 2017杭电多校第五场11Rikka with Competition
Rikka with Competition Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/O ...
- 2017杭电多校第五场Rikka with Subset
Rikka with Subset Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others ...
- [2019杭电多校第五场][hdu6630]permutation 2
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6630 题意为求出1-n,n个数的全排列中有多少种方案满足第一位为x,第n位为y,且相邻数字绝对值之差不 ...
- [2019杭电多校第五场][hdu6624]fraction
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6624 题意为求最小的b满足$a*b^{-1}\equiv x(modp)$. 把式子化简一下: $a\ ...
- [2019杭电多校第五场][hdu6629]string matching(扩展kmp)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6629 题意求字符串的每个后缀与原串的最长公共前缀之和. 比赛时搞东搞西的,还搞了个后缀数组...队友一 ...
- [2019杭电多校第五场][hdu6628]permutation 1
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6628 题意为求字典序第k小的差异数组,差异数组p满足p[i]=a[i+1]-a[i]. 头铁的爆搜,因 ...
- [2019杭电多校第五场][hdu6625]three arrays(01字典树)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6625 大意为给你两个数组a和b,对应位置异或得到c数组,现在可以将a,b数组从新排序求c数组,使得字典 ...
- 2019杭电多校第五场 discrete logarithm problem
https://vjudge.net/contest/317493#problem/I
随机推荐
- ASP.NET Core - 实现自定义WebApi模型验证
Framework时代 在Framework时代,我们一般进行参数验证的时候,以下代码是非常常见的 [HttpPost] public async Task<JsonResult> Sav ...
- Core CLR Host 源码简单分析
在定制 CLR Host的时候,可以通过调用如下代码,来获取当前需要被宿主的程序调用入口: hr = Host->CreateDelegate( domainId, L"Main,Ve ...
- 用python绘制漂亮的图形
先看效果,没有用任何绘图工具,只是运行了一段python代码. 代码如下: _ = ( 255, lambda V ,B,c :c and Y(V*V+B,B, c -1)if(abs(V)<6 ...
- win10家庭版打开组策略
新建记事本,输入: @echo off pushd "%~dp0" dir /b C:\Windows\servicing\Packages\Microsoft-Windows-G ...
- [译]Python中的异步IO:一个完整的演练
原文:Async IO in Python: A Complete Walkthrough 原文作者: Brad Solomon 原文发布时间:2019年1月16日 翻译:Tacey Wong 翻译时 ...
- CentOS 7.3下使用YUM 安装MySQL5.6
1.检查Linux系统中是否已安装 MySQL rpm -qa | grep mysql 返回空值的话,就说明没有安装 MySQL 注意:在新版本的CentOS7中,默认的数据库已更新为了Mariad ...
- 夯实Java基础(四)——面向对象之多态
1.多态介绍 面向对象三大特征:封装.继承.多态.多态是Java面向对象最核心,最难以理解的内容.从一定角度来看,封装和继承几乎都是为多态而准备的. 多态就是指程序中定义的引用变量所指向的具体类型和通 ...
- PHP 的一些底层知识
本篇内容比较干涩,请自备矿泉水 文章分6个主题进行讲解 PHP运行机制和原理 PHP底层变量数据结构 PHP传值赋值中的COW特性 PHP垃圾回收机制 PHP中数组底层分析 PHP数组函数分类 PHP ...
- Spring系列(二):Spring IoC应用
一.Spring IoC的核心概念 IoC(Inversion of Control 控制反转),详细的概念见Spring系列(一):Spring核心概念 二.Spring IoC的应用 1.定义B ...
- MyISAM和InnoDB在索引上的差别及其它区别
首先我们知道MyISM和InnoDB索引都是由B+树实现的,但在索引管理数据方式上却有所不同. InnoDB是聚集索引,数据文件是和(主键)索引绑在一起的,即索引 + 数据 = 整个表数据文件,通过主 ...