Luo Gu P3719 [AHOI2017 junior] rexp

Luo Gu P3719 [AHOI2017 junior] rexp

Topic background

The following is a simplified version does not affect the meaning of the title of the topic.

Title Description

It is given by the a (,), | sequence, a composition, a seeking of how many after Jane.

Simplification rules:

1, the form aa ... a | aa ... a | aa ... a, and the simplified result is "|" up to a number of sides of a, for example, a | aa | aaa = aaa 3, first count sequence with parentheses, for example (a | a) | aaa = aaa

Input Format

A sequence of line

Output Format

After a number of simplification

Sample input and output

Input # 1
aa(aa)|(aa|(a|aa))aa
Output # 1
4

Description / Tips

Sample remember the original title, only just write instead. . .

Sequence length not more than 100,000

Ensure legitimate and sequences in parentheses, and "|" about all non-empty

Solution

Seemingly written this title, similar to the P1022 improved calculator

But how do I feel this is a lot simpler than the calculator do?

P1022 or that I think is too complicated?

Algorithm

In P1022, we can use the idea of ​​classification Discussions + partition, but that question is not very clear, right

This question is very good with a partition made:

  1. You do not need to read the string
  2. You do not need to guess that store digital P1022
  3. You do not need to judge so many characters, such as =, +, -, * as well as hidden

So with the partition, then how to do it?

 

Guess you like

Origin www.cnblogs.com/send-off-a-friend/p/11618736.html