<PREV Problem:
NEXT>
Solved by 186 users: ...
UserDateAttemptTimeCMSC
V.A.KeRneL13 feb 2007Ruby200.022 
daniel.ugra10 jan 2007Ruby500.027 
daniel.ugra30 dec 2006Ruby200.0224 
cyberian29 apr 2007Python900.0728 
patronus29 apr 2007Python300.0629 
aruna17 may 2007Python100.0729 
cyberian29 apr 2007Python800.0632 
david_it2122 apr 2008Ruby300.0234 
cyberian29 apr 2007Python700.0636 
cyberian12 feb 2007Python500.0538 
BobicZdoh10 jan 2008Ruby700.0240 
jeeva20 may 2007Python100.0640 
priya_selvam20 may 2007Python100.0640 
Jayalakshmi20 may 2007Python100.0740 
Languages
C++
100
FPC
25
Java
17
C
16
Python
14
Kylix
7
Ruby
6
Perl
3
Scheme
1
 > 
 > 
 > 
 > 
 > 
 > 
 > 
 > 
 > 
 > 

Regular Expression II

Time limit = 3 second(s)

A given regular expression consists of a sequence of obligatory lexems and optional elements. Each optional element is a regular expression too. The regular expression has the following syntax:

regexp ::= ( lexem | '[' regexp ']' ) +

Lexem can be one of ascii characters except of square brackets.

For example, regular expression "a[b]" means "a" or "ab". Example of more complex regular expression:

abc[de[f]g][h]i[j]

You must give an answer whether the given string S matches against the given regular expression R. Maximal length of the string and regular expression does not exceed 1000 characters. The regualar expression is correct.

Input Two lines. The first contains S, the second contains R.

Output YES in case of matcing and NO in other case.

Input#1
[er[r]we]
erwe

Output#1
YES

Input#2
a[we[r[t[y[u]]]]]
awe

Output#2
YES

Input#3
a[we[r[t[y[u]]]]]
au

Output#3
NO


Author:

17 December 2003

<PREV | Problem set | Search related messages | NEXT>


© acm.mipt DevGroup
The page was generated in 200ms

SW soft NIX
ID = 34.205.93.2