Codeforces Round #754 (Div. 2) C. Dominant Character
如代码,一共有七种情况,注意不要漏掉 "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的更多相关文章
- 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这一点 ...
- Codeforces Round #367 (Div. 2) C. Hard problem(DP)
Hard problem 题目链接: http://codeforces.com/contest/706/problem/C Description Vasiliy is fond of solvin ...
- Codeforces Round #368 (Div. 2) A. Brain's Photos (水题)
Brain's Photos 题目链接: http://codeforces.com/contest/707/problem/A Description Small, but very brave, ...
- Codeforces Round #277 (Div. 2) 题解
Codeforces Round #277 (Div. 2) A. Calculating Function time limit per test 1 second memory limit per ...
- Codeforces Round #372 (Div. 2) A .Crazy Computer/B. Complete the Word
Codeforces Round #372 (Div. 2) 不知不觉自己怎么变的这么水了,几百年前做A.B的水平,现在依旧停留在A.B水平.甚至B题还不会做.难道是带着一种功利性的态度患得患失?总共 ...
- Codeforces Round #246 (Div. 2) D. Prefixes and Suffixes
D. Prefixes and Suffixes You have a string s = s ...
- Codeforces Round #677 (Div. 3) 题解
Codeforces Round #677 (Div. 3) 题解 A. Boring Apartments 题目 题解 简单签到题,直接数,小于这个数的\(+10\). 代码 #include &l ...
- 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 ...
- Codeforces Round #354 (Div. 2) ABCD
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
随机推荐
- 检查redis是否正常运行
[XX@XXX]$ ps -ef | grep redisXX 8047 1 0 10:06 ? 00:00:03 redis-server *:6379XX 9983 9802 0 11:2 ...
- Java多线程 | 02 | 线程同步机制
同步机制简介 线程同步机制是一套用于协调线程之间的数据访问的机制.该机制可以保障线程安全.Java平台提供的线程同步机制包括: 锁,volatile关键字,final关键字,static关键字,以 ...
- 电脑变WIFI:建立虚拟共享WIFI热点可查看WIFI密码windows中使用bat批处理命令提示符cmd创建教程含工具
台式机也可支持移动热点,Win10却提示"我们无法设置移动热点",今天我们就另辟蹊径来调教它. 建立和开启虚拟WIFI共享网络 Windows 7操作系统及以后支持承载网络,可 ...
- lua入门之环境搭建、第一个demo
前言 前段时间因为有些项目功能需要,自己研究了下lua,今天整理下,并以一个demo为示例演示 手机上的运行效果 分为几个步骤来逐步讲解. 1.lua介绍,为什么选择它? 2.环境安装 3.撸一个简单 ...
- golang常用库:日志记录库-logrus使用
介绍 logrus 它是一个结构化.插件化的日志记录库.完全兼容 golang 标准库中的日志模块.它还内置了 2 种日志输出格式 JSONFormatter 和 TextFormatter,来定义输 ...
- SpringCloud config native 配置
1.概述 最近项目使用springCloud 框架,使用config搭建git作为配置中心. 在私有化部署中,出现很多比较麻烦的和鸡肋的设计. 每次部署都需要安装gitlab 有些环境安装完gitla ...
- idea创建maven项目时一直在 Process Running
解决方案: 1.设置maven的配置 File--->Settings(Ctrl+Alt+S)--->Build--->Build Tools--->Maven--->R ...
- Django笔记&教程 6-2 表单(Form)基础操作
Django 自学笔记兼学习教程第6章第2节--表单(Form)基础操作 点击查看教程总目录 1 - 编写表单类 创建新的表单类的代码,一般写到一个专门的forms.py文件中(一般放在对应的app文 ...
- 菜鸡的Java笔记 第五 - java 程序逻辑控制
程序主要分为三种逻辑:顺序,分支,循环. if 分支语句 if分支语句是最为基础的分支操作,但是其有三种使用形式: if语句 if.....else 语句 if....else...if...el ...
- 双非本科进大疆(SP)!
哈喽,大家好,我是仲一.今天和大家分享的是一位优秀双非本科生上岸大疆的经历(羡慕哭了...). 今年4月底的时候,这位学弟和我分享了他拿下oppo,京东,联发科实习offer的经历,当时我还发了朋友圈 ...