安徽科技工程大学程序设计在线考试系统Ver3.0

诚信考试,杜绝作弊!

问题 M: 14_D : Multiple String Matching

内存限制:512 MB 时间限制:3 S 标准输入输出
题目类型:传统 评测方式:文本比较

题目描述

String Search 

Determine whether a text T includes a pattern P. Your program should answer for given queries consisting of Pi.

输入格式

In the first line, a text T is given. In the second line, an integer Q denoting the number of queries is given. 

In the following Q lines, the patterns Pi are given respectively.

输出格式

For each question, print 1 if the text includes Pi, or print 0 otherwise.

输入样例 复制

aabaaa
4
aa
ba
bb
xyz

输出样例 复制

1
1
0
0

数据范围与提示

Constraints

  • 1 ≤ length of T ≤ 1000000
  • 1 ≤ length of Pi ≤ 1000
  • 1 ≤ Q ≤ 10000
  • The input consists of alphabetical characters and digits