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 题意:给出一个字符串,一个操作次数,每次操作从当前字符串最右边的字符 ...
随机推荐
- H5拖拽事件的完整过程和语法
<!DOCTYPE HTML> <html> <head> <style type="text/css"> #div1 { widt ...
- 洛谷 U10223 Cx大帝远征埃及
题目背景 众所周知,Cx是一个宇宙大犇.Cx能文善武,一直在为大一统的实现而努力奋斗着.Cx将调用他的精锐军队,一个精锐士兵最多可以战胜十个埃及士兵.同时Cx是个爱才的人,他想要制定一份能使在占领埃及 ...
- TCP和流
http://www.cnblogs.com/lwzz/archive/2011/07/03/2096963.html TCP是一种流协议(stream protocol).这就意味着数据是以字节流的 ...
- vue 高度 动态更新计算 calcHeight watch $route
vue 高度 动态更新计算 calcHeight () { // this.tableHeight = window.innerHeight - 210 } }, mounted () { // co ...
- unix网络编程-配置unp.h头文件
第一步进入:www.unpbook.com,下载unp的随书代码.新建一个目录,将压缩包拷贝到这一目录下面,然后将压缩包直接解压:tar -zxvf 压缩包名.tar.gz 完成上一步后,进入到un ...
- 如何改android device monitor文件的权限
adb.exe在c/Android/platform-tools目录下,在这个目录下打开终端,然后adb shell,然后su http://blog.csdn.net/u012719153/arti ...
- 暑假集训 || 区间DP
区间DP 经典石子合并问题V1 复杂度 On3 int a[SZ], sum[SZ], f[SZ][SZ]; int main() { int n; scanf("%d", ...
- zeromq编译与应用
libzmq是c++语言开发的,正式版本在这里: https://github.com/zeromq/libzmq/releases 到这篇文件发布为止,正式稳定版是4.2.2 1,按照给出的链接下载 ...
- spring boot jar的生成
1)准备demo 2)打开idea项目结构 3)添加 4)按顺序 6)bulid 7)完成 查看out文件
- Thread和Runable的关系
Thread 是一个类 Runnable是一个接口 Thread是实现了Runnable接口的类,使得run支持多线程 因为类的单一继承原则,推荐多使用Runnable接口