给定一个字符串,每天可以记忆三个字符,求书写出整个字符串的天数。

每次确定要记忆的三个字母,并向后寻找,若有非三个字母其中一个,则重新开启一天记忆三个字母。

#include<cstdio>
#include<iostream>
using namespace std;
int t;
string s;
int main(){
scanf("%d",&t);
while(t--){
cin>>s;
char a='0',b='0',c='0';//记忆三个字母
bool f1=false,f2=false,f3=false;//三个字母是否有值
int ans=1;//刚开始天数为1
for(int i=0;i<s.size();i++){
if(f1&&f2&&f3){
if(s[i]!=a&&s[i]!=b&&s[i]!=c){//如果是未记忆,重新开启一轮
f1=false;
f2=false;
f3=false;//恢复状态
ans++;//天数+1
a='0';
b='0';
c='0';
}
else continue;
}
if(!f1&&s[i]!=b&&s[i]!=c){//寻找需记忆的三个字母
a=s[i];
f1=true;
continue;
}
if(!f2&&s[i]!=a&&s[i]!=c){
b=s[i];
f2=true;
continue;
}
if(!f3&&s[i]!=a&&s[i]!=b){
c=s[i];
f3=true;
continue;
}
}
printf("%d\n",ans);
}
return 0;
}

CF1702B Polycarp Writes a Srting from Memory 题解的更多相关文章

  1. Codeforces Round #479 (Div. 3)题解

    CF首次推出div3给我这种辣鸡做,当然得写份博客纪念下 A. Wrong Subtraction time limit per test 1 second memory limit per test ...

  2. 工作于内存和文件之间的页缓存, Page Cache, the Affair Between Memory and Files

    原文作者:Gustavo Duarte 原文地址:http://duartes.org/gustavo/blog/post/what-your-computer-does-while-you-wait ...

  3. Page Cache, the Affair Between Memory and Files

    Previously we looked at how the kernel manages virtual memory for a user process, but files and I/O ...

  4. PatentTips - Reducing Write Amplification in a Flash Memory

    BACKGROUND OF THE INVENTION Conventional NAND Flash memories move data in the background to write ov ...

  5. 【并行计算-CUDA开发】CUDA bank conflict in shared memory

    http://hi.baidu.com/pengkuny/item/c8070b388d75d481b611db7a 以前以为 shared memory 是一个万能的 L1 cache,速度很快,只 ...

  6. 【Codeforces】CF Round #592 (Div. 2) - 题解

    Problem - A Tomorrow is a difficult day for Polycarp: he has to attend \(a\) lectures and \(b\) prac ...

  7. Codeforces 997D(STL+排序)

    D. Divide by three, multiply by two time limit per test 1 second memory limit per test 256 megabytes ...

  8. Codeforces Round #479 (Div. 3)

    手速场2333,这群人贼牛逼!手速贼快!   A. Wrong Subtraction time limit per test 1 second memory limit per test 256 m ...

  9. Fedora 24中的日志管理

    Introduction Log files are files that contain messages about the system, including the kernel, servi ...

随机推荐

  1. python+pytest接口自动化(15)-日志管理模块loguru简介

    python自带日志管理模块logging,使用时可进行模块化配置,详细可参考博文Python日志采集(详细). 但logging配置起来比较繁琐,且在多进行多线程等场景下使用时,如果不经过特殊处理, ...

  2. filter/backdrop-filter 毛玻璃效果

    对于方式二采用的方式,如果存在边缘模糊程度不够,可以设置扩大伪元素范围(margin: -20px),父元素超出裁剪(overflow: hidden). <!DOCTYPE html> ...

  3. this-4

    ES6函数里的this指的是定义这个函数时外层代码的this,可以理解为:1.ES6箭头函数没有自己的this:2.ES6箭头函数的this是外层代码(定义时,非执行时,也就是词法作用域)this的引 ...

  4. 在Windows2003 server 64位系统上使用ArcEngine开发的WCF服务

    之前大篇文章提到,ESRI说AE10.0以后已经不支持WebService的发布,经过一段时间的测试,发现目前10.2.2版本开始的WCF服务都可以正常发布,且运行正常. 先说一下之前遇到的问题,本机 ...

  5. L2M-GAN: Learning to Manipulate Latent Space Semantics for Facial Attribute Editing阅读笔记

    L2M-GAN: Learning to Manipulate Latent Space Semantics for Facial Attribute Editing 2021 CVPR L2M-GA ...

  6. hexo + typora 图片插入解决办法

    Typora 是一款知名的 Markdown 编辑器,简单好用,体验良好.使用 hexo 搭建好博客后,主要是用 Markdown 来编写博客,typora 便是我的首选编辑器.但直接使用 typor ...

  7. NBMiner42.1版本发布,完全解锁30系LHR版本显卡

    2021年下半年,NVIDIA发布了LHR版本显卡,对显卡算力进行了限制. 2022年5月8日,NBMiner发布NBMiner_41.0版本,在最新的内核中加入了100%LHR解锁器,适用于Wind ...

  8. 浅谈BSGS和EXBSGS

    我的 BSGS 和各位犇犇的差不多,但是不需要求逆元 Luogu [ TJOI2007 ] 可爱的质数 原题展现 题目描述 给定一个质数 \(p\),以及一个整数 \(b\),一个整数 \(n\),现 ...

  9. python自动将新生成的报告作为附件发送并进行封装

    发送报告作为自动化部署来讲是一个重要的环节,废话不多说直接上代码吧,如果想更细致的了解内容查阅本博主上篇基本发送文章 特别叮嘱一下:SMTP协议默认端口25,qq邮箱SMTP服务器端口是465 别出丑 ...

  10. 给王心凌打Call的,原来是神奇的智能湖仓

    图文原创:谭婧(王凌老粉) "爷青回" "我们只是老了,并没有死." 谭老师作为老粉,热烈庆祝"甜心教主"王凌成为现象级翻红顶流. 只要地球 ...