Codeforces Round #533(Div. 2) B.Zuhair and Strings
链接:https://codeforces.com/contest/1105/problem/B
题意:
给一个字符串和k,连续k个相同的字符,可使等级x加1,
例:8 2 aaacaabb
则有aa aa 即x=2。
求最大的k
思路:
第一眼想的是诶个查找,但是绝对会T,就没做,过一个小时才想到可以直接遍历,记录每个字符对应的最大x即可。
代码:
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200000+10;
char s[MAXN];
int vis[26]; int main()
{
int n,k;
scanf("%d%d",&n,&k);
scanf("%s",s+1);
int now = 0;
for (int i = 1;i<=n;i++)
{
if (s[i] == s[i-1] || i == 1)
{
now++;
if (now == k)
{
vis[s[i] - 97]++;
now = 0;
} }
else
{
now = 1;
if (now == k)
{
vis[s[i] - 97]++;
now = 0;
}
}
}
int sum = 0;
for (int i = 0;i<26;i++)
sum = max(sum,vis[i]);
cout << sum << endl; return 0;
}
Codeforces Round #533(Div. 2) B.Zuhair and Strings的更多相关文章
- Codeforces Round #533 (Div. 2) B. Zuhair and Strings 【模拟】
传送门:http://codeforces.com/contest/1105/problem/B B. Zuhair and Strings time limit per test 1 second ...
- Codeforces Round #533 (Div. 2) B. Zuhair and Strings(字符串)
#include <bits/stdc++.h> using namespace std; int main() { int n,k;cin>>n>>k; stri ...
- Codeforces Round #533 (Div. 2)题解
link orz olinr AK Codeforces Round #533 (Div. 2) 中文水平和英文水平都太渣..翻译不准确见谅 T1.给定n<=1000个整数,你需要钦定一个值t, ...
- 水题 Codeforces Round #302 (Div. 2) A Set of Strings
题目传送门 /* 题意:一个字符串分割成k段,每段开头字母不相同 水题:记录每个字母出现的次数,每一次分割把首字母的次数降为0,最后一段直接全部输出 */ #include <cstdio> ...
- Codeforces Round #533 (Div. 2) Solution
A. Salem and Sticks 签. #include <bits/stdc++.h> using namespace std; #define N 1010 int n, a[N ...
- Codeforces Round #533 (Div. 2) C.思维dp D. 多源BFS
题目链接:https://codeforces.com/contest/1105 C. Ayoub and Lost Array 题目大意:一个长度为n的数组,数组的元素都在[L,R]之间,并且数组全 ...
- Codeforces Round #533 (Div. 2) C. Ayoub and Lost Array 【dp】
传送门:http://codeforces.com/contest/1105/problem/C C. Ayoub and Lost Array time limit per test 1 secon ...
- Codeforces Round #533(Div. 2) C.Ayoub and Lost Array
链接:https://codeforces.com/contest/1105/problem/C 题意: 给n,l,r. 一个n长的数组每个位置可以填区间l-r的值. 有多少种填法,使得数组每个位置相 ...
- Codeforces Round #533(Div. 2) D.Kilani and the Game
链接:https://codeforces.com/contest/1105/problem/D 题意: 给n*m的地图,最多9个人,同时有每个人的扩张次数(我开始以为是直线扩张最大长度..实际是能连 ...
随机推荐
- git多人协作冲突解决方法
http://www.trinea.cn/dev-tools/git-skill/ http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361 ...
- HDU2586 How far away? —— 倍增LCA
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2586 How far away ? Time Limit: 2000/1000 MS (Java/Ot ...
- 安装Nginx四层负载均衡
Nginx1.9开始支持tcp层的转发,通过stream实现的,而socket也是基于tcp通信. stream模块默认不安装的,需要手动添加参数:–with-stream,官方下载地址:downlo ...
- codeforces B. Coach 解题报告
题目链接:http://codeforces.com/problemset/problem/300/B 题目意思:给出n个students(n%3 = 0),编号依次为1-n,接下来有m行,每行有两个 ...
- 确定mapkeeper使用的leverdb库路径
目前libleveldb的a或so库有三个路径,/usr/lib, /usr/lib/x86_64-linux-gnu , /usr/local/lib 使用 ls -d -1 /usr/lib/* ...
- 清理html中空白符/空格/换行在行内元素中产生的间距
问题:行内元素之间产生间隔 原因:换行符,Tab制表符,空格产生间隔 解决方法: 1.行内元素写成一行 2.设置font-size为0px 把父级文本设置为0px; 再为需要显示文字的行内元素设置文字 ...
- CISCO-更新路由器IOS
1,查看flash,复制IOS文件名,再上传IOS 2,传送完毕查看下flash Router# show flash: 查看flash中的信息 Directory of flash: 1 -rw- ...
- 并不对劲的bzoj5322:loj2543:p4561:[JXOI2018]排序问题
题目大意 \(T\)(\(T\leq10^5\))组询问 每次给出\(n,m,l,r\),和\(n\)个数\(a_1,a_2,...,a_n\),要找出\(m\)个可重复的在区间\([l,r]\)的数 ...
- FTP:文件传输协议(指令及响应代码)
文件传输协议(FTP)使得主机间可以共享文件. FTP 使用 TCP 生成一个虚拟连接用于控制信息,然后再生成一个单独的 TCP 连接用于数据传输.控制连接使用类似 TELNET 协议在主机间交换命令 ...
- ascall文件和二进制文件
ascall文件可以打开让我们看你们的具体内容. 二进制文件打开我们看到的就是一堆乱码. ascall在换行时不同的平台不一样: windows上面用 \r\n linux上面用 \n 二进制的内容 ...