F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Problem J. Count The String

Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 135    Accepted Submission(s): 7


Problem Description
Define string A match with B if A is same as B replacing the ′*′ character in B with arbitrary number of characters (possible zero).
Given string S and T.
We want to know how many non-empty substrings in S can match with T.
The substring of S is defined as $S_L$$S_{L+1}$ . . . $S_R$(1 ≤ L ≤ R ≤ |S|), two substrings are considered different if L or R are different.
 

Input
Input is given from Standard Input in the following format:
S
T
Constraints
1 ≤ |S|, |T| ≤ 100000
characters in S are lowercase
characters in T are lowercase or character ′*′
, and there are at most 10 ′*′ in T
 

Output
Print one line denotes the number of non-empty substrings in S that can match with T
 

Sample Input
aaaa a*a abba a*a
 

Sample Output
6 1
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-05-05 06:04:16, Gzip enabled