codefroces 911G Mass Change Queries
题意翻译
给出一个数列,有q个操作,每种操作是把区间[l,r]中等于x的数改成y.输出q步操作完的数列.
输入输出格式
输入格式:
The first line contains one integer n n n ( 1<=n<=200000 1<=n<=200000 1<=n<=200000 ) — the size of array a a a .
The second line contains n n n integers a1 a_{1} a1 , a2 a_{2} a2 , ..., an a_{n} an ( 1<=ai<=100 1<=a_{i}<=100 1<=ai<=100 ) — the elements of array a a a .
The third line contains one integer q q q ( 1<=q<=200000 1<=q<=200000 1<=q<=200000 ) — the number of queries you have to process.
Then q q q lines follow. i i i -th line contains four integers l l l , r r r , x x x and y y y denoting i i i -th query ( 1<=l<=r<=n 1<=l<=r<=n 1<=l<=r<=n , 1<=x,y<=100 1<=x,y<=100 1<=x,y<=100 ).
输出格式:
Print n n n integers — elements of array a a a after all changes are made.
输入输出样例
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int c[][];
bool flag[][];
int n,a[],ans[];
void build(int rt,int l,int r)
{int i;
for (i=;i<=;i++)
c[rt][i]=i;
if (l==r) return;
int mid=(l+r)/;
build(rt<<,l,mid);
build(rt<<|,mid+,r);
}
void pushdown(int rt)
{int i;
for (i=;i<=;i++)
{
c[rt<<][i]=c[rt][c[rt<<][i]];
c[rt<<|][i]=c[rt][c[rt<<|][i]];
}
for (i=;i<=;i++)
c[rt][i]=i;
}
void update(int rt,int l,int r,int L,int R,int x,int y)
{int i;
if (l>=L&&r<=R)
{
for (i=;i<=;i++)
if (c[rt][i]==x) c[rt][i]=y;
return;
}
pushdown(rt);
int mid=(l+r)/;
if (L<=mid) update(rt<<,l,mid,L,R,x,y);
if (R>mid) update(rt<<|,mid+,r,L,R,x,y);
}
void query(int rt,int l,int r)
{
if (l==r)
{
ans[l]=c[rt][a[l]];
return;
}
int mid=(l+r)/;
pushdown(rt);
query(rt<<,l,mid);
query(rt<<|,mid+,r);
}
int main()
{int i,q,l,r,x,y;
cin>>n;
for (i=;i<=n;i++)
{
scanf("%d",&a[i]);
}
build(,,n);
cin>>q;
for (i=;i<=q;i++)
{
scanf("%d%d%d%d",&l,&r,&x,&y);
update(,,n,l,r,x,y);
}
query(,,n);
for (i=;i<n;i++)
printf("%d ",ans[i]);
cout<<ans[n]<<endl;
}
codefroces 911G Mass Change Queries的更多相关文章
- Mass Change Queries CodeForces - 911G (线段树合并)
链接 大意: 给定序列, 每次操作将区间[l,r]中的x全改为y, 最后输出序列 权值范围比较小, 对每个权值开一颗线段树, 每次将x合并到y上即可 #include <iostream> ...
- Mass Change Queries Codeforces - 911G
https://codeforces.com/contest/911/problem/G 没想到线段树合并还能这么搞.. 对每个权值建一个线段树(动态开点),如果权值为k的线段树上第i位为1,那么表示 ...
- [CF911G]Mass Change Queries
题目大意: 给你一个长度为n的数列a,按顺序进行以下m次操作,每次将区间[l,r]中的所有x变成y,问最后数列是怎样的. 思路: 线段树. 每个线段树结点上维护当前区间每个数分别会变成多少.时间复杂度 ...
- CF911G Mass Change Queries(线段树+暴力)
cf机子真的快. 其实这个题的维护的信息还是很巧妙的. 首先,观察到题目中涉及到,区间修改这个操作,然后最后只查询一次,我们不妨用线段树来维护这个过程. 但是貌似直接维护每个位置的值可能不太好维护. ...
- Educational Codeforces Round 35
Nearest Minimums 相同的数里最小的数里的最小距离 Solution Two Cakes Solution Three Garlands 瞎比试 Solution Inversion C ...
- How To Do Master Record Mass Maintenance
How To Do Master Record Mass Maintenance Which master records mass maintenance can be done? What do ...
- SAP事务码 一
SE80 -- edit source code. SE24 -- class create or display. SFP -- created and maintained independent ...
- 解析大型.NET ERP系统 十三种界面设计模式
成熟的ERP系统的界面应该都是从模板中拷贝出来的,各类功能的界面有规律可遵循.软件界面设计模式化或是艺术性的创作,我认可前者,模式化的界面客户容易举一反三,降低学习门槛.除了一些小部分的功能界面设计特 ...
- Database Schemas Found in Oracle E-Business Suite
https://docs.oracle.com/cd/E26401_01/doc.122/e22952/T156458T659606.htm Table of Database Schemas in ...
随机推荐
- 使用git将文件上传到Coding
1,首先在Coding上新建项目. 2,填写项目的相关内容. 3,建立项目后复制下面鼠标所选内容. 4,在自己的电脑中建立文件夹. 5,进入该文件夹后,点击鼠标右键,然后再点Git Clone. 6 ...
- Beta冲刺随笔集合
Beta冲刺随笔集合 项目Beta预备 Beta冲刺第一天 Beta冲刺第二天 Beta冲刺第三天 Beta冲刺第四天 Beta冲刺第五天 Beta冲刺第六天 Beta冲刺第七天 用户调查报告 Bet ...
- 学号:201621123032 《Java程序设计》第3周学习总结
1:本周学习总结 1. 写出你认为本周学习中比较重要的知识点关键词. 类,对象,封装,继承,方法. 2. 用思维导图或者Onenote或其他工具将这些关键词组织起来 2:书面作业 2.1:以面向对象方 ...
- 《高级软件测试》web测试实践--12月30日记录
考完数学,我们正式开始web测试实践的作业,今天,我们主要进行了方案的选择和人员的分工.任务计划和安排如上图所示. 任务进展:完成题目选择和人员分工: 遇到问题:暂无: 下一步任务:完成软件评测.用户 ...
- SENet
 \(\bf F_{tr}\) 为标准卷积操作 \(\bf F_{sq}\) 为 Global Average Pooling \(\bf F_{ex}\) 为两层全连接网络(可以看做两个1×1卷积 ...
- Ubuntu安装使用latex
TeX Live is a TeX distribution to get up and running with the TeX document production system. To ins ...
- Windows中添加自己的程序到开机启动中(添加服务,添加注册表)
在系统启动的时候启动自己想要启动的程序: 方法一:利用开机启动文件夹 将exe文件或exe文件的快捷方式复制到(启动)文件夹下 以win7为例:开始→所有程序→启动→鼠标右键打开 方法二:添加系统服务 ...
- node请求下载接口时乱码
先说下问题 之前做的一个项目,三端同时开发(PC.WEB.APP),由于架构方面的原因,服务均不对外开放,接口地址自然也就不对外暴露了,所有请求都要经过node转发,此为背景.... 网站有个扫描二维 ...
- os.getcwd()、sys.path[0]、sys.argv[0]和__file__的区别,终于弄清楚了
os.getcwd().sys.path[0].sys.argv[0]和__file__的区别 要分清这几个的区别与使用条件,实际测试一下是最准确的. 设计测试方法: 一个主模块用来运行,一个子模块用 ...
- Python内置函数(61)——eval
英文文档: eval(expression, globals=None, locals=None) The arguments are a string and optional globals an ...