题意:https://codeforces.com/group/ikIh7rsWAl/contest/259944/problem/D

给你q个操作,4个数n,a,k,c,从n好位置开始每次加a的位置变成字符c,加到k次停止。

思路:

首先肯定是从下往上修改,改完就可以不再考虑该位置了。

1.对于a公差大于根号n的我们直接更新。

2.对于a公差小于根号n的,我们存根号n个数组,长度为n,对每个a公差分别用并查集维护下一个要的数,每个数最多使用一次。

 #define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#include <cstdio>//sprintf islower isupper
#include <cstdlib>//malloc exit strcat itoa system("cls")
#include <iostream>//pair
#include <fstream>//freopen("C:\\Users\\13606\\Desktop\\Input.txt","r",stdin);
#include <bitset>
//#include <map>
//#include<unordered_map>
#include <vector>
#include <stack>
#include <set>
#include <string.h>//strstr substr strcat
#include <string>
#include <time.h>// srand(((unsigned)time(NULL))); Seed n=rand()%10 - 0~9;
#include <cmath>
#include <deque>
#include <queue>//priority_queue<int, vector<int>, greater<int> > q;//less
#include <vector>//emplace_back
//#include <math.h>
#include <cassert>
#include <iomanip>
//#include <windows.h>//reverse(a,a+len);// ~ ! ~ ! floor
#include <algorithm>//sort + unique : sz=unique(b+1,b+n+1)-(b+1);+nth_element(first, nth, last, compare)
using namespace std;//next_permutation(a+1,a+1+n);//prev_permutation
//******************
clock_t __STRAT,__END;
double __TOTALTIME;
void _MS(){__STRAT=clock();}
void _ME(){__END=clock();__TOTALTIME=(double)(__END-__STRAT)/CLOCKS_PER_SEC;cout<<"Time: "<<__TOTALTIME<<" s"<<endl;}
//***********************
#define rint register int
#define fo(a,b,c) for(rint a=b;a<=c;++a)
#define fr(a,b,c) for(rint a=b;a>=c;--a)
#define mem(a,b) memset(a,b,sizeof(a))
#define pr printf
#define sc scanf
#define ls rt<<1
#define rs rt<<1|1
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long ll;
const double E=2.718281828;
const double PI=acos(-1.0);
const ll INF=(1LL<<);
const int inf=(<<);
const double ESP=1e-;
const int mod=(int)1e9+;
const int N=(int)1e5+;
int l[][N],r[][N],n;bool f[*N];
void Init(int n)
{
for(int i=;i<=;++i)
{
for(int j=;j<=N-;++j)
{
r[i][j]=j;
}
}
}
int findr(int pos,int x)
{
if(r[x][pos]==pos)
return pos;
else
return r[x][pos]=findr(r[x][pos],x);
}
void del(int pos)
{
for(int i=;i<=;++i)
{
r[i][pos]=findr(min(pos+i,n+),i);
}
}
char s[N];
struct node
{
int a,b,c;
char d[];
}op[N];
/*
xaaaaaaaaaaaaaaaaaaa
3
4 2 8 b
6 3 4 c
10 5 2 d
*/
int main()
{
sc("%s",s+);
n=strlen(s+);
Init(n);
int q;
sc("%d",&q); for(int i=;i<=q;++i)
sc("%d%d%d%1s",&op[i].a,&op[i].b,&op[i].c,&op[i].d[]);
int x=;
for(int i=q;i>=;--i)
{
if(op[i].b>x)
{
for(int j=op[i].a,k=;j<=n&&k<=op[i].c;j+=op[i].b,++k)
{
if(f[j])continue;
s[j]=op[i].d[];
f[j]=;
del(j);
}
}
else
{
int j=op[i].a;
while(j<=op[i].a+op[i].b*op[i].c)
{
if(!f[j])
{
f[j]=;
s[j]=op[i].d[];
del(j);
}
j=findr(j,op[i].b);
}
}
}
pr("%s\n",s+);
return ;
} /**************************************************************************************/

Do Not Try This Problem(分块思想)的更多相关文章

  1. Codeforces Round #319 (Div. 1)C. Points on Plane 分块思想

                                                                              C. Points on Plane On a pl ...

  2. hdu_5085_Counting problem(莫队分块思想)

    题目连接:hdu_5085_Counting problem 题意:给你一个计算公式,然后给你一个区间,问这个区间内满足条件的数有多少个 题解:由于这个公式比较特殊,具有可加性,我们考虑讲一个数分为两 ...

  3. 莫队算法 sqrt(n)分块思想

    在此说一下本渣对莫队算法思想的一些浅薄理解 莫队算法的思想就是对真个区间的分块,然后按照每块来分别进行计算,这样最终的复杂度可以达到n*sqrt(n) 小Z的袜子是一道非常经典的题目.:题目链接htt ...

  4. [BZOJ 2957]楼房重建(THU2013集训)(分块思想)

    题目:http://www.lydsy.com/JudgeOnline/problem.php?id=2957 分析: 首先明确问题,对于每栋楼房的斜率K=H/X,问题就是问有多少个楼房的K比前面所有 ...

  5. ZOJ 1654 Place the Robots建图思维(分块思想)+二分匹配

    题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=654 AC一百道水题,不如AC一道难题来的舒服. 题意:一个n*m地图 ...

  6. 构造+分块思想 Codeforces Round #319 (Div. 1) C

    http://codeforces.com/contest/576/problem/C 题目大意: 给你一个曼哈顿距离的图,然后要求你找到一个链,链穿了所有的点 然后要求这链的长度<=25*10 ...

  7. PAT1057 stack(分块思想)

    1057 Stack (30分)   Stack is one of the most fundamental data structures, which is based on the princ ...

  8. HDOJ 4858 项目管理 ( 只是有点 莫队的分块思想在里面而已啦 )

    题目: 链接:http://acm.hdu.edu.cn/showproblem.php?pid=4858 题意: 我们建造了一个大项目!这个项目有n个节点,用很多边连接起来,并且这个项目是连通的! ...

  9. cf666 C. Codeword 组合数学 离线分块思想

                      time limit per test 6 seconds memory limit per test 256 megabytes input standard i ...

随机推荐

  1. zabbix4.2升级后中文字体乱码解决方法.

    字体文件目录: zabbix 4.2 /usr/share/zabbix/assets/fonts/ 4.0 /usr/share/zabbix/fonts/ php 脚本文件位置: /usr/sha ...

  2. 如何在vue中使用svg

    1.安装依赖 npm install svg-sprite-loader --save-dev 2.在config文件中配置    const path = require('path'); func ...

  3. gitlab 配置.ssh实现免密登陆

    首次配置gitlab的.ssh时 安装gitbash 通过gitbash 配置.ssh 打开gitbash,输入如下命令生成ssh,邮箱换成自己的 ssh-keygen -t rsa -C " ...

  4. redhat7.4安装svn

    1.使用yum install subversion出错 已加载插件:langpacks, product-id, search-disabled-repos, subscription-manage ...

  5. 程序猿必备的Git教程

    http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000 版权声明:本文为博主原创文章,未经 ...

  6. 你的windows许可证即将过期

    0xC004F025拒绝访问:所请求的操作需要提升特权:解决方法:1.打开我的电脑找到windows System32目录下的cmd                 2.对windows System ...

  7. 算法的时间复杂度——"大O分析法"(转载)

    原文地址:https://my.oschina.net/gooke/blog/684026 一下为本人笔记:) 场景:在解决计算机科学领域的问题时,经常有好多个方法都可以,想找到最优的方法,就有了时间 ...

  8. Parameter 'list1' not found. Available parameters are [list] 解析

    在使用foreach语句时会经常报Parameter ‘ordersList’ not found. Available parameters are [list] 解析这个错误,造成这个错误的主要原 ...

  9. PHP学习之工厂方法模式

    <?php //工厂方法模式 interface Doing { function eat(); function sleep(); } class Cat implements Doing { ...

  10. hadoop1.2.1安装配置

    原文地址 环境:ubuntu13 使用的用户为普通用户.如:用户ru jdk安装略 1.安装ssh (1) sudo apt-get install openssh-server (2)配置ssh面密 ...