cf796部分题解
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部分题解的更多相关文章
- 2016 华南师大ACM校赛 SCNUCPC 非官方题解
我要举报本次校赛出题人的消极出题!!! 官方题解请戳:http://3.scnuacm2015.sinaapp.com/?p=89(其实就是一堆代码没有题解) A. 树链剖分数据结构板题 题目大意:我 ...
- noip2016十连测题解
以下代码为了阅读方便,省去以下头文件: #include <iostream> #include <stdio.h> #include <math.h> #incl ...
- BZOJ-2561-最小生成树 题解(最小割)
2561: 最小生成树(题解) Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 1628 Solved: 786 传送门:http://www.lyd ...
- Codeforces Round #353 (Div. 2) ABCDE 题解 python
Problems # Name A Infinite Sequence standard input/output 1 s, 256 MB x3509 B Restoring P ...
- 哈尔滨理工大学ACM全国邀请赛(网络同步赛)题解
题目链接 提交连接:http://acm-software.hrbust.edu.cn/problemset.php?page=5 1470-1482 只做出来四道比较水的题目,还需要加强中等题的训练 ...
- 2016ACM青岛区域赛题解
A.Relic Discovery_hdu5982 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Jav ...
- poj1399 hoj1037 Direct Visibility 题解 (宽搜)
http://poj.org/problem?id=1399 http://acm.hit.edu.cn/hoj/problem/view?id=1037 题意: 在一个最多200*200的minec ...
- 网络流n题 题解
学会了网络流,就经常闲的没事儿刷网络流--于是乎来一发题解. 1. COGS2093 花园的守护之神 题意:给定一个带权无向图,问至少删除多少条边才能使得s-t最短路的长度变长. 用Dijkstra或 ...
- CF100965C题解..
求方程 \[ \begin{array}\\ \sum_{i=1}^n x_i & \equiv & a_1 \pmod{p} \\ \sum_{i=1}^n x_i^2 & ...
- JSOI2016R3 瞎BB题解
题意请看absi大爷的blog http://absi2011.is-programmer.com/posts/200920.html http://absi2011.is-programmer.co ...
随机推荐
- [转帖]Linux内存之Cache
一. Linux内存之Cache 1.1.Cache 1.1.1.什么是Cache? Cache存储器,是位于CPU和主存储器DRAM之间的一块高速缓冲存储器,规模较小,但是速度很快,通常由SRAM( ...
- [转帖]strace分析sqlplus登录慢问题
一. 问题分析 有时会遇到sqlplus / as sysdba登录非常慢的问题,由于还没登录,通过数据库等待事件一般看不出来啥,需要用到strace这个分析利器.strace有很多参数,后面会列出, ...
- [转帖]使用S3F3在Linux实例上挂载Bucket
https://docs.jdcloud.com/cn/object-storage-service/s3fs S3F3是基于FUSE的文件系统,允许Linux 挂载Bucket在本地文件系统,S3f ...
- [转帖]jmap执行失败了,怎么获取heapdump?
https://www.jianshu.com/p/f4bfd169b4ca 在之前的OOM问题复盘中,我们添加了jmap脚本来自动dump内存现场,方便排查OOM问题. 但当我反复模拟OOM场景 ...
- Bash 脚本发送消息到企业微信的办法
1. Study From https://www.cnblogs.com/elvi/p/11444388.html 2. 申请或者使用已经有的企业微信. 首先是获取一下企业id 方法如图: 3. 创 ...
- 一条sql了解MYSQL的架构设计
1 前言 对于一个服务端开发来说 MYSQL 可能是他使用最熟悉的数据库工具,然而,大部分的Java工程师对MySQL的了解和掌握程度,大致就停留在这么一个阶段:它可以建库.建表.建索引,然后就是对里 ...
- 火狐谷歌浏览器去掉input type=number时控件的方法
html 默认:<input type="number" /></br> 处理:<input type="number" clas ...
- MybatisPlus对Mysql数据库关键字作为列名的处理--SQLSyntaxErrorException: You have an error in your SQL syntax;
说明: 在设计数据库时,使用mysql关键字作为列名(比如order用于排序),就会报错:java.sql.SQLSyntaxErrorException: You have an error in ...
- python入门之后须掌握的知识点(模块化编程、时间模块)【一】
相关文章: 全网最详细超长python学习笔记.14章节知识点很全面十分详细,快速入门,只用看这一篇你就学会了! python入门合集: python快速入门[一]-----基础语法 python快速 ...
- vi / vim编辑器的使用 [补档-2023-07-01]
vi/vim编辑器 vi/vim编辑器是linux中的文本编辑器,其中vim比vi的功能更加强大,可以编辑shell程序,推荐使用vim,下面也将介绍vim如何使用. 2-1 vi/vim的三种工 ...