zstuoj 4246 萌新吃果果
来源:互联网 发布:java xss 编辑:程序博客网 时间:2024/05/20 16:32
点击打开链接
输入的时候直接构造序列,O(n)。
#include<bits/stdc++.h>#define ll long longconst int maxn=100000+100000;char team[maxn];using namespace std;int main(){ int T,ans,n,k,i,j,t; char c; scanf("%d",&T); while(T--){ scanf("%d%d",&n,&k); getchar();ans=0,t=0; for(i=0;ans<=n;){ scanf("%c",&c);ans++; if(!i) {i++;continue;} else{ if(c=='a'){ team[i++]=c;t++; }else if(c=='b'){ if(team[i-1]=='a') { team[i++]='0'; t=0; } team[i++]='b';t++; }else{ int f=0; if(t>=k) f=1; if(f) { team[i++]='0';t=0; } team[i++]='c';t++; } } } printf("%d\n",i-1); } return 0;}
0 0
- zstuoj 4246 萌新吃果果
- zstuoj 4355
- 【浙江理工大学2016年新生赛暨全国新生邀请赛】 J 萌新吃果果,ZSTUOJ 4286【模拟】
- String Game【ZSTUOJ--4212】
- Jug Hard【ZSTUOJ--4216】
- ZSTUOJ 4215 Landlocked
- ZSTUOJ 4212 String Game
- zstuoj 4243 牛吃草
- zstuoj 4243 牛吃草
- zstuoj 4274 约素
- zstuoj 4269 买iphone
- ZSTUOJ 4266 回文
- zstuoj 4270: 同源数
- ZSTUOJ 4273: 玩具
- ZSTUOJ 4270: 同源数
- ZSTUOJ 4362:不要方
- zstuoj 2853 算术表达式 模拟
- zstuoj 4242 校庆 4244 众数
- 我的第一份工作,久远银海
- 图像处理与计算机视觉开源软件库
- 第十三周项目一-Prim算法的验证
- C# 反射机制详解
- angularJS之自定义服务与fliter的混合使用
- zstuoj 4246 萌新吃果果
- leetcode 383. Ransom Note
- UIWebView - 使用方法总结
- 字符串首字母转大写
- js-sdk invalid signature错误
- oracle commit提交之后的数据恢复!
- Webservice服务创建、调用
- SAP HANA应该如何学习?
- AHUOJ级语言程序设计实验(六)直角三角形