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. 【面试题精讲】Redis如何实现分布式锁

    首发博客地址 系列文章地址 Redis 可以使用分布式锁来实现多个进程或多个线程之间的并发控制,以确保在给定时间内只有一个进程或线程可以访问临界资源.以下是一种使用 Redis 实现分布式锁的常见方法 ...

  2. [转帖]六千字带你了解 Oracle 统计信息和执行计划

    https://cloud.tencent.com/developer/article/1616706 大家好,我是 JiekuXu,很高兴又和大家见面了,今天分享下 Oracle 统计信息和执行计划 ...

  3. Intel 移动CPU天梯榜

    Intel酷睿i9-13980HX 2023 2121 Intel酷睿i9-13900HX 2023 2051 Intel酷睿i9-13950HX 2023 2005 4 + Intel酷睿i9-12 ...

  4. [转帖]Linux fuse用户态文件系统及其libfuse

    https://www.jianshu.com/p/abc5524ac18c 为什么要有用户态文件系统 VFS文件系统可知文件系统在内核态的,应用程序操作文件,统一调用内核态的VFS层抽象接口. 突然 ...

  5. Kafka学习之四_Grafana监控相关的学习

    Kafka学习之四_Grafana监控相关的学习 背景 想一并学习一下kafaka的监控. 又重新开始学习grafana了: 下载地址: https://grafana.com/grafana/dow ...

  6. JVM启动速度大页内存验证

    大页内存设置 先查看 cat /proc/meminfo |grep -i huge 获取大页内存的大小信息. AnonHugePages: 42022912 kB HugePages_Total: ...

  7. 关于SSL证书的学习与总结

    关于证书 证书是用来实现https通信加密的基础, 有证书才能够进行相关的TLS层的加密处理. 本文简要讲解一下证书的申请,创建以及使用等. 第一部分: PKI 公共密钥基础 其实有很多家企业在做PK ...

  8. vue3中context.emit遇见的坑

    场景描述 今天遇见一个问题 ,子组件向上抛出去的事件. 被执行了两次,原因是 context.emit('click', item.id) 你的事件名是click 将click更改为其他事件名称,就可 ...

  9. 通杀无限 debugger,目前只有 1% 的人知道!

    前言 相信很多小伙伴在进行 web 逆向的时候,都遇到过无限 debugger.最简单的方法,在 debugger 位置,点击行号,右键 Never pause here,永远不在此处断下即可.但是这 ...

  10. Govulncheck v1.0.0 发布了!

    原文在这里 原文作者:Julie Qiu, for the Go security team 发布于 13 July 2023 我们很高兴地宣布,govulncheck v1.0.0 已经发布,同时还 ...