链接:

http://codeforces.com/contest/828/problem/E

题解:

给你一个字符串s  q次操作 op==1 改变s[pos]位置的字符  op==2 将字符串e复制无限次 求从l开始s[l] == e[0]  ,s[l+1] == e[1] ...... s[r] == e[r-l]成立的有多少个

题解:

开一个C[10][10][4][n],第二维表示e的长度,第一维表示i%e的长度,第三维表示颜色,第四维求和了

代码:

31 int T[12][12][4][MAXN];
32 int n;
33
34 void add(int a, int b, int c, int d, int x) {
35     while (d <= n) T[a][b][c][d] += x, d += d&-d;
36 }
37
38 int sum(int a, int b, int c, int d) {
39     int res = 0;
40     while (d) res += T[a][b][c][d], d -= d&-d;
41     return res;
42 }
43
44 int main() {
45     ios::sync_with_stdio(false), cin.tie(0);
46     map<char, int> mmp;
47     mmp['A'] = 0;
48     mmp['T'] = 1;
49     mmp['G'] = 2;
50     mmp['C'] = 3;
51     string s;
52     cin >> s;
53     n = s.length();
54     rep(i, 0, n) rep(j, 1, 11) add(i%j, j, mmp[s[i]], i + 1, 1);
55     int q;
56     cin >> q;
57     while (q--) {
58         int k;
59         cin >> k;
60         if (k == 1) {
61             int x;
62             char c;
63             cin >> x >> c;
64             x--;
65             rep(j, 1, 11) {
66                 add(x%j, j, mmp[s[x]], x + 1, -1);
67                 add(x%j, j, mmp[c], x + 1, 1);
68             }
69             s[x] = c;
70         }
71         else {
72             int l, r;
73             string e;
74             cin >> l >> r >> e;
75             l--, r--;
76             int len = e.length();
77             int res = 0;
78             rep(i, 0, len)
79                 res += sum((l + i) % len, len, mmp[e[i]], r + 1)
80                 - sum((l + i) % len, len, mmp[e[i]], l);
81             cout << res << endl;
82         }
83     }
84     return 0;
85 }

转载于:https://www.cnblogs.com/baocong/p/7209344.html

Codeforces Round #423 (Div. 2, rated, based on VK Cup Finals) E. DNA Evolution 树状数组相关推荐

  1. Codeforces Round #423 (Div. 2, rated, based on VK Cup Finals) C. String Reconstruction 并查集

    C. String Reconstruction 题目连接: http://codeforces.com/contest/828/problem/C Description Ivan had stri ...

  2. D. Best Edge Weight(最小生成树 + 树链剖分)(Codeforces Round #423 (Div. 1, rated, based on VK Cup Finals))

    D. Best Edge Weight 给定一个有nnn个点mmm条边的无向连通图,有mmm次询问,每次询问第iii条边的权值最大为多少,这张图的所有最小生成树的方案中,一定包含第iii条边. 先跑一 ...

  3. Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals)

    昨晚的没来得及打,最近错过好几场CF了,这场应该不算太难 A. Unimodal Array time limit per test 1 second memory limit per test 25 ...

  4. Codeforces Round #396 (Div. 2) E. Mahmoud and a xor trip 二进制拆位+树型dp

    E. Mahmoud and a xor trip 链接: http://codeforces.com/contest/766/problem/E 题意: 给定一颗n节点的树以及每个节点的权值,另di ...

  5. Codeforces Round #826 (Div. 3)(D. Masha and a Beautiful Tree)线段树解法

    题目大意:输入包含 t ( 1 ≤ t ≤ 1e4 ) 组测试样例,每组样例先输入 m 大小的数组,构建一棵满二叉树.问是否可以通过交换根节点的子树让序列变成升序. 思路 我们在树的每个节点记录下区间 ...

  6. Codeforces Round #504 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final)切题报告(A-B题)

    这是我第二次参加CF比赛,也是第一次写博客,写得不好,望各位大佬海涵. A. Single Wildcard Pattern Matching 原题链接 这道题,这是难到让人无法直视,太水了. 题目大 ...

  7. Codeforces Round #740 (Div. 2, based on VK Cup 2021 - Final (Engine))

    Codeforces Round #740 (Div. 2, based on VK Cup 2021 - Final (Engine)) 题号 题目 知识点 A Simply Strange Sor ...

  8. Codeforces Round #740 (Div. 2, based on VK Cup 2021 - Final (Engine)) A-F全题解

    Codeforces Round #740 (Div. 2, based on VK Cup 2021 - Final (Engine)) 文章目录 A. Simply Strange Sort B. ...

  9. C. Tyler and Strings(组合数学,树状数组维护前缀和)(Codeforces Round #775 (Div. 1, based on Moscow Open Olympiad i)

    对我来说比较困难的一题了,尝试着自己写了一下,调不出来遂放弃. Codeforces Round #775 (Div. 1, based on Moscow Open Olympiad in Info ...

最新文章

  1. 记录一次MySQL两千万数据的大表优化解决过程,提供三种解决方案 1
  2. 无法启动python怎么办_解决python写的windows服务不能启动的问题
  3. 通过 .gitlab-ci.yml配置任务-官方配置文件翻译
  4. 西南大学网络教育学院计算机基础,西南大学网络与继续教育学院课程考试计算机基础【1056】...
  5. python中datetime模块_python中的datetime模块
  6. 回溯法求解N皇后问题(Java实现)
  7. 【ES】ES 如何在一个机器上同时模拟多个node
  8. 分布式系统认证方案_分布式系统介绍_Spring Security OAuth2.0认证授权---springcloud工作笔记134
  9. 织梦 html5视频显示问题,织梦网站HTML5 video视频播放器(不用安装插件)
  10. 10大Go语言开源项目推荐
  11. 《Linux运维总结:SVN提示Node remains in conflict解决办法》
  12. 5GC 网元介绍(AMF、SMF、UPF、UDM、PCF)
  13. 【嵌入式系统】STM32时钟系统+时钟配置函数解析
  14. Centos7开小鸡(centos7安装KVM+kimchi+wok开小鸡)第一篇安装kimchi wok
  15. mumu的adb_MuMu进行adb操作
  16. 不从装VS6 MSDN
  17. android+微信分享代码,Android 微信分享icon黑边代码解决
  18. RT-Thread物联网操作系统介绍:10、计数信号量
  19. 数据类型与数据结构 文件读写及绘图
  20. Java IO流学习总结三十一:File

热门文章

  1. request.getcontextPath() 详解
  2. 由于使用zen coding导致myeclipse6.5中使用Alt+/不自动提示的解决办法
  3. 菜鸟程序员的成长之路-工作篇
  4. clip\_gradient
  5. 【正一专栏】希望才是深深让人绝望的东西-论国足
  6. VC对话框最小化到托盘
  7. Leetcode 313. 超级丑数 解题思路及C++实现
  8. DNS协议报文(RFC1035)
  9. springsecurity的工作原理
  10. Shiro实现认证_ini