hdu 5745 La Vie en rose(2016多校第二场) La Vie en rose
Time Limit: 14000/7000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 643 Accepted Submission(s):
328
Problem Description
Professor Zhang would like to solve the multiple
pattern matching problem, but he only has only one pattern string n , Professor Zhang wants to find all occurrences of all the generated patterns in
s .
Input
There are multiple test cases. The first line of input
contains an integer T , indicating the number of test cases. For each test case:
The first line contains two integers p . Both the strings consist of only lowercase English letters.
The first line contains two integers p . Both the strings consist of only lowercase English letters.
Output
For each test case, output a binary string of length
1 is one of the generated patterns.
Sample Input
3
4 1
abac
a
4 2
aaaa
aa
9 3
abcbacacb
abc
Sample Output
1010
1110
100100100
Author
zimpha
题意:输入两个字符串s串和p串,p串从s串的第一个字符开始一直比较到最后一个(如果后面字符比p串段,则肯定输出0),比较的时候若不相同,则p串的字符可以相邻交换进行比较,每个位置只能交换一次,(只是当前比较的交换,而不是永久交换),相同字符串输出1,不同则输出0。
纯暴力,从第一个字符开始比较就好。
附上代码:
1 #include <iostream> 2 #include <cstdio> 3 #include <cmath> 4 #include <cstring> 5 #define ll long long 6 using namespace std; 7 char s1[110005],s2[5005]; 8 int main() 9 { 10 int T,i,j; 11 scanf("%d",&T); 12 while(T--) 13 { 14 int len1,len2; 15 memset(s1,'