Match the string--hdu1797(模拟)
http://acm.hdu.edu.cn/showproblem.php?pid=1797
就是模拟
我的思路是标记aba 和h的位置
然后就判断是否正确 就行了
还有就是 最后 fkfkfkfk交叉也可以
#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <math.h>
#include <ctype.h> using namespace std;
#define memset(a,b) memset(a,b,sizeof(a))
#define N 101000
typedef long long ll;
char str[N]; int main()
{
int T; scanf("%d",&T);
while(T--)
{
int flag=;
scanf("%s",str);
int len=strlen(str);
int abc,h;
abc=h=-;
if(strstr(str,"aba"))
abc=strstr(str,"aba")-str;
if(strstr(str,"h"))
h=strstr(str,"h")-str;
if(abc==- || h==- || h==len-)
flag=;
for(int i=; i<abc; i++)
{
if(str[i]!='a')
{
flag=;
break;
}
}
int v1=,v2=;
for(int i=abc+; i<h; i++)
{
if(str[i]!='b' && str[i]!='d')
{
flag=;
break;
}
if(str[i]=='d' && str[i]=='b')
{
flag=;
break;
}
if(str[i]=='b')
v1++;
if(str[i]=='d')
v2++;
}
if(v1!= && v2==)
flag=;
if(v1>)
flag=;
v1=v2=;
for(int i=h+; str[i]; i++)
{
if(str[i]!='f' && str[i]!='k')
{
flag=;
break;
}
if(str[i]=='f')
v1++;
if(str[i]=='k')
v2++;
}
if(v1== && v2==)
flag=;
if(v1== && v2== && v1!=v2)
flag=;
if(flag==)
printf("NO\n");
else
printf("YES\n");
}
return ;
}
Match the string--hdu1797(模拟)的更多相关文章
- Oracle问题之literal does not match format string
问题: oerr ora 186101861, 00000, "literal does not match format string"// *Cause: Literals i ...
- 解决sqoop 导入oracle表时 --split-by参数为日期类型时的报错:ORA-01861: literal does not match format string
报错栈: -- ::, INFO [main] org.apache.sqoop.mapreduce.db.DBRecordReader: Executing query: select " ...
- 解决:Oracle 异常 ORA-01861: literal does not match format string(字符串格式不匹配)
今天在写存储过程的时候,老是报一个错.如下,记录下来,以供日后查阅. 报错: Oracle 异常 ORA-01861: literal does not match format string(字符 ...
- Codeforces Round #550 (Div. 3) E. Median String (模拟)
Median String time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...
- 2018.08.22 NOIP模拟 string(模拟)
string [描述] 给定两个字符串 s,t,其中 s 只包含小写字母以及*,t 只包含小写字母. 你可以进行任意多次操作,每次选择 s 中的一个*,将它修改为任意多个(可以是 0 个)它的前一个字 ...
- Codeforces Round #550 (Div. 3) E. Median String (思维,模拟)
题意:给你两个字符串\(s\)和\(t\),保证\(t\)的字典序大于\(s\),求他们字典序中间的字符串. 题解:我们假设题目给的不是字符串,而是两个10禁止的正整数,那么输出他们之间的数只要把他两 ...
- 【CF1015B】Obtaining the String(模拟)
题意:给定两个字符串,每次可以交换相邻两个字符,给出任意一组交换次数小于1e4的方案使得a串成为b串,输出交换的次数与位置,无解输出-1 n<=50 思路:每次找到第一个不相同的字符,从后面找到 ...
- csu - 1536: Bit String Reordering (模拟)
http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1536 不知道为何怎么写都写不对. 这题可以模拟. 虽然题目保证一定可以从原串变成目标串,但是不一定 ...
- UVaLive 6832 Bit String Reordering (模拟)
题意:给定一个01序列,然后让你你最少的操作数把这它变成目标. 析:由于01必须是交替出现的,那么我们就算两次,然后取最值. 代码如下: #pragma comment(linker, "/ ...
- String Successor(模拟)
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3490 题意:给出一个字符串,一个操作次数,每次操作从当前字符串最右边的字符 ...
随机推荐
- JSP 错误处理方法
web.xml中配置error-page标签 1.WEB工程中打开 web.xml 文件
- 全文索引Elasticsearch,Solr,Lucene
最近项目组安排了一个任务,项目中用到了全文搜索,基于全文搜索 Solr,但是该 Solr 搜索云项目不稳定,经常查询不出来数据,需要手动全量同步,而且是其他团队在维护,依赖性太强,导致 Solr 服务 ...
- react基础语法(一)元素渲染和基础语法规则
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- 详解nginx.conf文件配置项(包括负载均衡)
http://www.cnblogs.com/hsapphire/archive/2010/04/08/1707109.html #运行用户 user nobody nobody; #启动进程 wo ...
- uva 1451 数形结合
思路:枚举点t,寻找满足条件的点t': 计sum[i]为前i项合,平均值即为sum[t]-sum[t'-1]/t-t'+1 设(Pi=(i,Si),表示点在s中的位置,那么就可以画出坐标图,问题就转化 ...
- promise 里面的 console.info 打印信息 并不准确,后期有修改对象数据,会覆盖,影响之前的显示
promise 里面的 console.info 打印信息 并不准确,后期有修改对象数据,会覆盖,影响之前的显示
- QT+ 状态栏+核心控件+浮动窗口
#include "mainwindow.h" #include <QStatusBar> #include <QLabel> #include<QT ...
- 日常[系统]:Linux新人报到(吐槽%&%……&¥……%
昨天换了系统,从win7换到了NOIP必须面对的Linux系统. 不得不说,真的很不适应.原本右上角的三个按钮变到了左上角. 可爱的DEVCPP被无情的抛弃了. 又用不惯guide,只好用文本编辑器写 ...
- zabbix auto registration
1./etc/zabbix/zabbix_agent.conf serverActive=zabbix server ip 2.frontend configuration>actions> ...
- Openjudge-2815-城堡问题
对于这道题目来说的话,我们的思路是这样的,我们首先把数据读进来,然后把color数组清零. 我们的思路是这样的的,给每一个房间设置一个对应的color数组,然后color数组里面填满不同的数字,每一种 ...