题目:

HDU 6356

http://acm.hdu.edu.cn/showproblem.php?pid=6356

很裸的线段树

#include<bits/stdc++.h>
#define fi first
#define se second
#define INF 0x3f3f3f3f
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pqueue priority_queue
#define NEW(a,b) memset(a,b,sizeof(a))
#define si(x) scanf("%lld",&x)
#define lowbit(x) (x&(-x))
#define lc (d<<1)
#define rc (d<<1|1)
#define eps 1e-9
const double pi=4.0*atan(1.0);
const double e=exp(1.0);
const int maxn=1e7+;
typedef long long LL;
typedef unsigned long long ULL;
//typedef pair<LL,LL> P;
const LL mod=**;
const ULL base=1e7+;
using namespace std;
unsigned x,y,z,w;
unsigned RNG(){
x=x^(x<<);
x=x^(x>>);
x=x^(x<<);
x=x^(x>>);
w=x^(y^z);
x=y;
y=z;
z=w;
return z;
}
struct node{
int l,r,mi,lz;
}a[maxn];
void build(int l,int r,int d){
a[d].l=l;
a[d].r=r;
a[d].mi=a[d].lz=;
if(l!=r){
int mid=(a[d].l+a[d].r)>>;
build(l,mid,lc);
build(mid+,r,rc);
}
}
void add(int l,int r,int d,int x){
if(l==a[d].l&&r==a[d].r){
a[d].lz=max(x,a[d].lz);
a[d].mi=max(x,a[d].mi);
return ;
}
if(x<=a[d].mi){
return ;
}
int mid=(a[d].l+a[d].r)>>;
if(a[d].lz!=){
add(a[d].l,mid,lc,a[d].lz);
add(mid+,a[d].r,rc,a[d].lz);
a[d].lz=;
}
if(l>mid){
add(l,r,rc,x);
}
else if(r<=mid){
add(l,r,lc,x);
}
else{
add(l,mid,lc,x);
add(mid+,r,rc,x);
}
a[d].mi=min(a[lc].mi,a[rc].mi);
}
int query(int l,int r,int d){
if(l==a[d].l&&r==a[d].r){
return a[d].mi;
}
int mid=(a[d].l+a[d].r)>>;
if(a[d].lz!=){
add(a[d].l,mid,lc,a[d].lz);
add(mid+,a[d].r,rc,a[d].lz);
a[d].lz=;
}
if(l>mid){
return query(l,r,rc);
}
else if(r<=mid){
return query(l,r,lc);
}
}
int main(){
fio;
int t;
cin>>t;
int n,m;
while(t--){
w=;
cin>>n>>m>>x>>y>>z;
build(,n,);
unsigned f1,f2,f3;
LL l,r,v;
for(int i=;i<=m;i++){
f1=RNG();
f2=RNG();
f3=RNG();
l=min((f1%n)+,(f2%n)+);
r=max((f1%n)+,(f2%n)+);
v=f3%mod;
add(l,r,,v);
}
LL res=;
for(int i=;i<=n;i++){
res^=1ll*i*(query(i,i,));
}
cout<<res<<endl;
}
}

线段树模板(HDU 6356 Glad You Came)的更多相关文章

  1. 线段树模板hdu 1754:I Hate It

    I Hate It Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total S ...

  2. 线段树模板 hdu 1166 敌兵布阵

    敌兵布阵 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submis ...

  3. 线段树模板hdu 1166:敌兵布阵

    敌兵布阵 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submis ...

  4. hdu 4819 二维线段树模板

    /* HDU 4819 Mosaic 题意:查询某个矩形内的最大最小值, 修改矩形内某点的值为该矩形(Mi+MA)/2; 二维线段树模板: 区间最值,单点更新. */ #include<bits ...

  5. HDU 1166 线段树模板&树状数组模板

    HDU1166 上好的线段树模板&&树状数组模板 自己写的第一棵线段树&第一棵树状数组 莫名的兴奋 线段树: #include <cstdio> using nam ...

  6. HDU 1698 Just a Hook (线段树模板题-区间求和)

    Just a Hook In the game of DotA, Pudge’s meat hook is actually the most horrible thing for most of t ...

  7. HDU1166:敌兵布阵(线段树模板)

    敌兵布阵 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submis ...

  8. [AHOI 2009] 维护序列(线段树模板题)

    1798: [Ahoi2009]Seq 维护序列seq Time Limit: 30 Sec  Memory Limit: 64 MB Description 老师交给小可可一个维护数列的任务,现在小 ...

  9. hdu1754 I hate it线段树模板 区间最值查询

    题目链接:这道题是线段树,树状数组最基础的问题 两种分类方式:按照更新对象和查询对象 单点更新,区间查询; 区间更新,单点查询; 按照整体维护的对象: 维护前缀和; 维护区间最值. 线段树模板代码 # ...

  10. P3373 线段树模板

    好,这是一个线段树模板. #include <cstdio> using namespace std; ; long long int sum[N],tag1[N],tag2[N],mo; ...

随机推荐

  1. css写复选框

    前面讲过<完全使用css编写复选框>,后来在深入学习sass过程中,发现:这种写法虽然也能达到目的,但是稍嫌复杂了一点.这里介绍一种可以说更简单一点的方法,其实也就是html结构更简单一点 ...

  2. IntelliJ IDEA 注释模板设置

    1.idea类注释 打开:file->setting->Editor->Filr and Code Templates->Includes->File Header 类注 ...

  3. RecyclerView通用适配器

    在Android开发中使用列表呈现数据的情况很多,现在我们常用RecyclerView呈现列表,为了开发敏捷和代码优雅,我们现在来打造<?xml version="1.0" ...

  4. Ignoring query to other database

    Ignoring query to other database 自己今天刚遇到,进入MySQL的时候,输入show databases; 产生如下错误 错误提示 Ignoring query to  ...

  5. VC中明明已经添加了头文件却还提示未定义的问题

    我在VS中编译程序遇到这个错误:error C3861: 'ReadDirectoryChangesW': identifier not found, even with argument-depen ...

  6. 浅谈 foreach 的原理

    package com.shenzhou; import java.util.ArrayList; import java.util.Iterator; import java.util.List; ...

  7. 机器学习进阶-直方图与傅里叶变换-图像直方图 1.cv2.calc(生成图像的像素频数分布(直方图))

    1. cv2.calc([img], [0], mask, [256], [0, 256])  # 用于生成图像的频数直方图 参数说明: [img]表示输入的图片, [0]表示第几个通道, mask表 ...

  8. Spring boot 配置文件 加载顺序

    springboot 启动会扫描以下位置的application.properties或者application.yml文件作为Spring boot的默认配置文件 –file:./config/ – ...

  9. 分布式ID生成学习

    唯一 && 趋势有序 数据库auto_increment,多个写库时,每个写库不同的初始值和相同的步长(A(0,2)B(1,2)) 缺点:非绝对递增,写库压力大 DB只保存序列最大值, ...

  10. Indy 10.5.8 for Delphi and Lazarus 修改版(2011)

    Indy 10.5.8 for Delphi and Lazarus 修改版(2011)    Internet Direct(Indy)是一组开放源代码的Internet组件,涵盖了几乎所有流行的I ...