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命令(64)——strings命令
https://cloud.tencent.com/developer/article/1414999 1.命令简介 strings命令是二进制工具集GNU Binutils的一员,用于打印文件中可打 ...
- [转帖]Linux下清理内存和Cache方法见下文:
https://www.cnblogs.com/the-tops/p/8798630.html 暂时目前的环境处理方法比较简单: 在root用户下添加计划任务: */10 * * * * sync;e ...
- [转帖]tidb关闭sql_mode=ONLY_FULL_GROUP_BY模式
报错: 1 of ORDER BY clause is not in SELECT list, references column 'xxx' which is not in SELECT list ...
- requests模块安装
使用python写接口,必不可少的就是requests,所以事先要在python中安装requests 一.使用pip install安装(项目的命令行终端使用) 1.配置下载源地址路径(清 ...
- 深度解析C#数组对象池ArrayPool<T>底层原理
提到池化技术,很多同学可能都不会感到陌生,因为无论是在我们的项目中,还是在学习的过程的过程,都会接触到池化技术.池化技术旨在提高资源的重复使用和系统性能,在.NET中包含以下几种常用的池化技术. (1 ...
- Flask闪现
目录 九.闪现 9.1 什么是闪现? 九.闪现 9.1 什么是闪现? -设置:flash('aaa') -取值:get_flashed_message() - -假设在a页面操作出错,跳转到b页面,在 ...
- miniIO系列文章03---abpvext中集成
在Abp商业版本中已经提供了文件管理模块的,免费版本是没有的,本文将介绍如何使用Minio打造一个自己的文件管理模块. 在项目开始之前,需要先安装一个Minio服务,可以在本地pc或云主机中安装,具体 ...
- nodejs的npm改为国内源和参数
npm源改为国内 此方法不需要安装cnpm也可以使用淘宝镜像,提高国内访问速度 由于 Node 的官方模块仓库网速太慢,模块仓库需要切换到阿里的源. npm config set registry h ...
- 【一】分布式训练---单机多卡多机多卡(飞桨paddle1.8)
1.分布式训练简介 分布式训练的核心目的: 加快模型的训练速度.通过对训练任务按照一定方法拆分分配到多个计算节点进行计算,再按照一定的方法对需要汇总的信息进行聚合,从而实现加快训练速度的目的. 1.1 ...
- 5.11 汇编语言:仿写IF条件语句
条件语句,也称为IF-ELSE语句,是计算机编程中的一种基本控制结构.它允许程序根据条件的真假来执行不同的代码块.条件语句在处理决策和分支逻辑时非常有用.一般来说,条件语句由IF关键字.一个条件表达式 ...