<PREV Problem:
NEXT>
Solved by 66 users: ...
UserDateAttemptTimeCMSC
bush11 feb 2013Ruby504.1379 
zhuojie28 oct 2009Python105.7186 
kornakovBSU14 jul 2009C++2100.0687 
DAV03 jun 2009C++2600.0787 
DAV02 jun 2009C++2400.0791 
DAV02 jun 2009C++2300.0793 
DAV02 jun 2009C++1900.0798 
abortmozga.ru09 may 2009C++2600.04104 
abortmozga.ru09 may 2009C++2300.04105 
abortmozga.ru09 may 2009C++1800.04107 
abortmozga.ru09 may 2009C++1900.04107 
DAV03 jun 2009C++2700.07109 
abortmozga.ru09 may 2009C++1700.04111 
mikelan08 mar 2012C500.10144 
Philip_PV28 jul 2009C++300.07147 
ethanhunt31 may 2011C++900.08151 
ethanhunt31 may 2011C++1000.05152 
ethanhunt31 may 2011C++800.05154 
Philip_PV28 jul 2009C++200.07157 
ethanhunt31 may 2011C++700.05158 
FordPerfect27 feb 2010C++200.08165 
fetetriste30 apr 2009C++100.30167 
Languages
C++
50
Java
6
Kylix
4
C
3
Ruby
1
Python
1
FPC
1
 > 
 > 
 > 
 > 
 > 
 > 
 > 
 > 
 > 
 > 

Brackets III

Time limit = 1 second

Memory limit = 64 Mb

You are given a string consisting of the brackets "<",">"; "(",")"; "{","}"; "[","]". The problem is to find the number of substrings that are the regular brackets sequence (RBS).

The definition of RBS: RBS + RBS = RBS, <RBS> = RBS, (RBS) = RBS, [RBS] = RBS, (RBS) = RBS.

Examples of RBS: (), ([]), <>()[](<>){{}}, <{{{}}()}>.

Input A string consisting of characters "(","[","{","<",">","}","]",")". The length of the line does not exceed 106 characters.

Output Number of substrings that are RBS.

Input#1
}<>(){)(<})[]
Output#1
4

Input#2
((><))>{<>}[[])
Output#2
3

Author:
Egor Malyshev
28 april 2009

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


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

SW soft NIX
ID = 3.214.224.224