题目:Problem - C - Codeforces

如代码,一共有七种情况,注意不要漏掉  "accabba"  , "abbacca"  两种情况;

使用find()函数可简化代码,使用方法如下

代码:

#include <iostream>
using namespace std;
typedef long long ll;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
ll T;
cin >> T;
while (T--)
{
ll n, ans = -1;
string s;
cin >> n >> s;
if (s.find("accabba") != s.npos)
ans = 7;
if (s.find("abbacca") != s.npos)
ans = 7;
if (s.find("acba") != s.npos)
ans = 4;
if (s.find("abca") != s.npos)
ans = 4;
if (s.find("aba") != s.npos)
ans = 3;
if (s.find("aca") != s.npos)
ans = 3;
if (s.find("aa") != s.npos)
ans = 2;
cout << ans << endl;
}
return 0;
}

Codeforces Round #754 (Div. 2) C. Dominant Character的更多相关文章

  1. Codeforces Round #754 (Div. 2), problem: (A) A.M. Deviation泪目 万万没想到狂wa是因为这

    Problem - A - Codeforces 题目 题意很简单每次操作可以使得a1 a2  a3任意两个数分别+1  -1 求最后使得a+c-2b绝对值的最小值 BUG就是最后忽略了-2和2这一点 ...

  2. Codeforces Round #367 (Div. 2) C. Hard problem(DP)

    Hard problem 题目链接: http://codeforces.com/contest/706/problem/C Description Vasiliy is fond of solvin ...

  3. Codeforces Round #368 (Div. 2) A. Brain's Photos (水题)

    Brain's Photos 题目链接: http://codeforces.com/contest/707/problem/A Description Small, but very brave, ...

  4. Codeforces Round #277 (Div. 2) 题解

    Codeforces Round #277 (Div. 2) A. Calculating Function time limit per test 1 second memory limit per ...

  5. Codeforces Round #372 (Div. 2) A .Crazy Computer/B. Complete the Word

    Codeforces Round #372 (Div. 2) 不知不觉自己怎么变的这么水了,几百年前做A.B的水平,现在依旧停留在A.B水平.甚至B题还不会做.难道是带着一种功利性的态度患得患失?总共 ...

  6. Codeforces Round #246 (Div. 2) D. Prefixes and Suffixes

                                                        D. Prefixes and Suffixes You have a string s = s ...

  7. Codeforces Round #677 (Div. 3) 题解

    Codeforces Round #677 (Div. 3) 题解 A. Boring Apartments 题目 题解 简单签到题,直接数,小于这个数的\(+10\). 代码 #include &l ...

  8. Codeforces Round #366 (Div. 2) ABC

    Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...

  9. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

随机推荐

  1. docker创建本地主机实例Virtualbox 驱动出错

    宿主机系统:Centos7 64位 创建主机实例Virtualbox 命令:docker-machine create -d virtualbox test 连接centos工具:Finalshell ...

  2. Python-爬取CVE漏洞库👻

    Python-爬取CVE漏洞库 最近吧准备复现一下近几年的漏洞,一个一个的去找太麻烦了.今天做到第几页后面过几天再来可能就不记得了.所以我想这搞个爬虫给他爬下来做个excel表格,那就清楚多了.奈何还 ...

  3. 【不费脑筋系列】发布个人的代码包到Nuget服务器上,并通过VS引用进行使用的方法

      打打酱油,写点不需要费脑筋的博客先压压惊. 下面讲个关于个人如何开发nuget包,并部署到nuget服务器上的例子.为了保证.net framework和 .net core都可以访问到我的包,我 ...

  4. Django笔记&教程 6-2 表单(Form)基础操作

    Django 自学笔记兼学习教程第6章第2节--表单(Form)基础操作 点击查看教程总目录 1 - 编写表单类 创建新的表单类的代码,一般写到一个专门的forms.py文件中(一般放在对应的app文 ...

  5. SeleniumLibrary 主要关键字 基于python3

    关键字的解释 https://blog.csdn.net/ak739105231/article/details/88926995 click element 都是元素点击事件:不赘述 click l ...

  6. 在 Kubernetes 上安装 Gitlab CI Runner Gitlab CI 基本概念以及 Runner 的安装

    简介 从 Gitlab 8.0 开始,Gitlab CI 就已经集成在 Gitlab 中,我们只要在项目中添加一个.gitlab-ci.yml文件,然后添加一个Runner,即可进行持续集成.在介绍 ...

  7. python实现图片色素的数值运算(加减乘除)和逻辑运算(与或非异或)

    目录: (一)数值运算(加减乘除) (二)逻辑运算(与或非异或) 正文: (一)数值运算(加减乘除) opencv自带图片色素的处理函数------相加:add()   相减:subtract()  ...

  8. python实现开闭操作

    目录: 开闭操作的作用 (一)开操作 (二)闭操作 (三)开操作完成其他任务 (1)提取水平垂直线 (2)消除干扰线 (3)提取满足要求的形状 开闭操作的作用: (一)开操作(特点作用:消除噪点--- ...

  9. [gym102770L]List of Products

    有一个很重要的性质:若$a\le b$且$c\le d$,则$ac\le bd$ 根据这一性质,就可以利用单调性$o(n)$求出小于$a_{x}\cdot b_{y}$的数的个数(先要对$a$和$b$ ...

  10. [bzoj1107]驾驶考试

    转化题意,如果一个点k符合条件,当且仅当k能到达1和n考虑如果l和r($l<r$)符合条件,容易证明那么[l,r]的所有点都将会符合条件,因此答案是一个区间枚举答案区间[l,r],考虑如何判定答 ...