<JZOJ5912>VanUSee
挺魔的
反正我考场上想不到233333333333333
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rint register int
using std::sort;
using std::cin;
template <class T>inline void read(T &X)
{
X=;int W=;char ch=;
while(!isdigit(ch))W|=ch=='-',ch=getchar();
while(isdigit(ch))X=(X<<)+(X<<)+(ch^),ch=getchar();
X=W?-X:X;return;
}
int n,m,t,tot1,tot2;
int ou[],next[],ji[],tmp;
char S[],T[];
bool ok1,ok2,ok;
int main()
{
freopen("vanusee.in","r",stdin);
freopen("vanusee.out","w",stdout);
read(t);
while (t--)
{
ok1=ok2=ok=;
cin>>S+;
cin>>T+;
n=strlen(S+),m=strlen(T+);
tot1=tot2=;
for (rint i=,j=;i<=m;i++)
{
while (T[i]!=T[j+]&&j) j=next[j];
if (T[i]==T[j+]) j++;
next[i]=j;
}
for (rint i=,j=;i<=n;i++)
{
while (S[i]!=T[j+]&&j) j=next[j];
if (S[i]==T[j+]) j++;
if (j==m)
{
tmp=n-i+m-i;
if (!((n-m)%)) ou[++tot1]=tmp;
else ji[++tot2]=tmp;
j=next[j];
}
}
if ((n-m)%)
{
sort(ji+,ji+tot2+);
for(rint i=;i<=tot2;i++)
if(ji[i]-ji[i-]==) ou[++tot1]=ji[i]-;
}
for (rint i=;i<=tot1;i++)
{
if (!ou[i]){ok=;break;}
if (ou[i]==) ok1=;
if (ou[i]==-) ok2=;
}
if (ok) {printf("pty\n");continue;}
if (!ok1 || !ok2) printf("cqf\n");
else printf("pty\n");
}
}
<JZOJ5912>VanUSee的更多相关文章
- [JZOJ 5912] [NOIP2018模拟10.18] VanUSee 解题报告 (KMP+博弈)
题目链接: https://jzoj.net/senior/#contest/show/2530/2 题目: 众所周知,cqf童鞋对哲学有着深入的理解和认识,并常常将哲学思想应用在实际生活中,例如锻炼 ...
- [NOIP2018模拟赛10.18]自闭报告
闲扯 这一天,菜鸡RyeCatcher又想起来了被毒瘤题支配的恐惧 今天比较好玩,还是ljy提醒才发现文件夹里有题面...不知道外面的人什么时候才发现 看完了题面,又回到了雅礼啥题也不会写的感觉 T1 ...
随机推荐
- js中要声明变量吗?
你好,js语言是弱类型语言,无需申明即可直接使用,默认是作为全局变量使用的.建议:在function里时应使用var 申明变量,这样改变量仅仅只在function的生存周期内存在,不会污染到,全局控件 ...
- 吴裕雄--天生自然深度学习TensorBoard可视化:命名空间
# 1. 不同的命名空间. import tensorflow as tf with tf.variable_scope("foo"): a = tf.get_variable(& ...
- Ivory Coast Map
Fun Facts about Cote d'Ivoire The Republic of Cote d'Ivoire (previously known as the Ivory Coast) is ...
- VS Code之Vue开发常用插件
Auto Close Tag 自动补全html标签 Auto Rename Tag 同步更改html尾标签 ESLint ESlint语法提示 settings.json 文件 "eslin ...
- Docker搭建RabbitMQ(阿里云)
0 环境 系统环境:centos7 服务器:阿里云 1 正文 1 获取安装RabbitMQ https://hub.docker.com/_/rabbitmq 默认rabbitmq镜像是不带web端管 ...
- oracle 导入导出参数
- TPO1-1groundwater
Thus a proportion of the total volume of any sediment, loose or cemented, consists of empty space. M ...
- DFS-BFS(深搜广搜)原理及C++代码实现
深搜和广搜是图很多算法的基础,很多图的算法都是从这两个算法中启发而来. 深搜简单地说就是直接一搜到底,然后再回溯,再一搜到底,一直如此循环到没有新的结点. 广搜简单地说就是一层一层的搜,像水的波纹一样 ...
- mysql模糊匹配like及批量替换replace
1.mysql 模糊匹配 like 与 not like 用法 : SELECT * FROM `user` where `nickname` LIKE '%测试%' SELECT * FROM `u ...
- Traffic Network in Numazu
Traffic Network in Numazu 题目描述 Chika is elected mayor of Numazu. She needs to manage the traffic in ...