C. Manipulating History

题意:给出一些字符串,有原始串(只含一个字符的串)、被替换的串、替换串、
最终串(最后一行),求原始串。 2
a
ab
b
cd
acd Initially s is "a".
In the first operation, Keine chooses "a", and replaces it with "ab". s becomes "ab".
In the second operation, Keine chooses "b", and replaces it with "cd". s becomes "acd".
So the final string is "acd", and t=["a", "ab", "b", "cd"] before being shuffled.

思路:统计所有字母出现的次数,个数为奇数的就是最终结果。

因为每个串,他被替换的时候会给出它,然后它在替换前也是有的,

所以每次替换操作得到的结果都会是偶数。

//不要转成0-25,不然会超时
#include<bits/stdc++.h>
#define endl '\n'
using namespace std; const int N = 210;
const int M = 1e5 + 10;
int t, n, k, cnt;
int a[N];
string st;
vector<int> vet;
map<string, int> mp; signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> t;
while(t --){
cin >> n;
memset(a, 0, sizeof a);
for(int i = 1; i <= 2 * n + 1; i ++){
string st;
cin >> st;
for(int j = 0; j < st.size(); j++){
int x = (int)(st[j]);
a[x] ++;
}
}
for(int i = 0; i < 200; i ++){
if(a[i] % 2 == 1){
char ch = (char)(i);
cout << ch << endl;
break;
}
}
}
return 0;
}

D. The Enchanted Forest

题意:给n个数,每个位置代表初始时,当前位置有多少个蘑菇,每单位时间每个位置都会长出来1个蘑菇,
问,在给定时间k内,最多能获得多少蘑菇? 如果k >= n, 那么就先待在初始位置,等到刚好能全摘完所有蘑菇的时间,再去进行移动。
如果k < n, 那么就找出来最大连续子串。
#include<bits/stdc++.h>
#define endl '\n'
#define int long long
using namespace std; const int N = 2e5 + 10;
int t, n, k;
int sum[N], a[N]; signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> t;
while(t --){
cin >> n >> k;
for(int i = 1; i <= n; i++){
cin >> a[i];
a[i] = a[i - 1] + a[i];
}
int ans = 0;
if(k >= n){
ans = a[n];
ans += (k - n) * n;
for(int i = 0; i <n; i++) ans += i;
}
else{
for(int i = k; i <= n; i++){
ans = max(a[i] - a[i - k], ans);
}
for(int i = 1; i < k; i++) ans += i;
}
cout << ans << endl;
}
return 0;
}

cf796部分题解的更多相关文章

  1. 2016 华南师大ACM校赛 SCNUCPC 非官方题解

    我要举报本次校赛出题人的消极出题!!! 官方题解请戳:http://3.scnuacm2015.sinaapp.com/?p=89(其实就是一堆代码没有题解) A. 树链剖分数据结构板题 题目大意:我 ...

  2. noip2016十连测题解

    以下代码为了阅读方便,省去以下头文件: #include <iostream> #include <stdio.h> #include <math.h> #incl ...

  3. BZOJ-2561-最小生成树 题解(最小割)

    2561: 最小生成树(题解) Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 1628  Solved: 786 传送门:http://www.lyd ...

  4. Codeforces Round #353 (Div. 2) ABCDE 题解 python

    Problems     # Name     A Infinite Sequence standard input/output 1 s, 256 MB    x3509 B Restoring P ...

  5. 哈尔滨理工大学ACM全国邀请赛(网络同步赛)题解

    题目链接 提交连接:http://acm-software.hrbust.edu.cn/problemset.php?page=5 1470-1482 只做出来四道比较水的题目,还需要加强中等题的训练 ...

  6. 2016ACM青岛区域赛题解

    A.Relic Discovery_hdu5982 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Jav ...

  7. poj1399 hoj1037 Direct Visibility 题解 (宽搜)

    http://poj.org/problem?id=1399 http://acm.hit.edu.cn/hoj/problem/view?id=1037 题意: 在一个最多200*200的minec ...

  8. 网络流n题 题解

    学会了网络流,就经常闲的没事儿刷网络流--于是乎来一发题解. 1. COGS2093 花园的守护之神 题意:给定一个带权无向图,问至少删除多少条边才能使得s-t最短路的长度变长. 用Dijkstra或 ...

  9. CF100965C题解..

    求方程 \[ \begin{array}\\ \sum_{i=1}^n x_i & \equiv & a_1 \pmod{p} \\ \sum_{i=1}^n x_i^2 & ...

  10. JSOI2016R3 瞎BB题解

    题意请看absi大爷的blog http://absi2011.is-programmer.com/posts/200920.html http://absi2011.is-programmer.co ...

随机推荐

  1. [转帖]SQL SERVER中隐式转换的一些细节浅析

    https://www.cnblogs.com/kerrycode/p/5853257.html 其实这是一篇没有技术含量的文章,精通SQL优化的请绕道.这个缘起于在优化一个SQL过程中,同事问了我一 ...

  2. [转帖]ls 只显示目录

    https://www.cnblogs.com/lavin/p/5912369.html 只显示目录: ls -d */ 在实际应用中,我们有时需要仅列出目录,下面是 4 种不同的方法. 1. 利用 ...

  3. [转帖]TiDB 内存控制文档

    https://docs.pingcap.com/zh/tidb/stable/configure-memory-usage 目前 TiDB 已经能够做到追踪单条 SQL 查询过程中的内存使用情况,当 ...

  4. [转帖]使用 BR 命令行备份恢复

    TiDB试用 来源:TiDB  浏览 404 扫码 分享 2021-04-20 20:49:42 使用 BR 命令行进行备份恢复 BR 命令行描述 命令和子命令 常用选项 使用 BR 命令行备份集群数 ...

  5. [转帖]数据可视化之redash(支持43种数据源) (转自https://anjia0532.github.io/2019/07/08/redash/)

    https://www.cnblogs.com/a00ium/p/13177272.html 人类都是视觉动物,讲究一图胜千言.如果没了可视化,那么你在跟领导汇报工作时,很大程度会鸡同鸭讲.其实 ex ...

  6. [转帖] Linux文本命令技巧(下)

    https://www.cnblogs.com/codelogs/p/16060108.html 简介# 前一篇介绍了Linux中一些基本的文本命令与使用技巧,但是结合场景过少,本篇结合工作中一些常见 ...

  7. [转帖]QPS、TPS、RT、并发数、吞吐量理解和性能优化深入思考

    https://baijiahao.baidu.com/s?id=1675704570461446033&wfr=spider&for=pc 吞吐量 在了解qps.tps.rt.并发数 ...

  8. Docker machine学习

    1. docker-machine 安装. From docker 官网 curl -L https://github.com/docker/machine/releases/download/v0. ...

  9. 同步存储读取vuex中store中的值

    main.js import store from "./store"; Vue.prototype.$store = store; 在 store中的index.js中 impo ...

  10. ILRuntime性能测试

    我们公司有一个Unity原生开发语言C#写的项目,目前已经在安卓测试过多次,上架IOS在考虑热更,所以对ILRuntim进行性能测试,在测试过程中已经按照官方文档进行了CLR绑定和生成Release的 ...